Object not declared in scope

Posted by jay on Stack Overflow See other posts from Stack Overflow or by jay
Published on 2010-03-08T16:01:16Z Indexed on 2010/03/08 16:06 UTC
Read the original article Hit count: 396

Filed under:
|
|

I'm using Xcode for C++ on my computer while using Visual Studio at school. The following code worked just fine in Visual Studio, but I'm having this problem when using Xcode.

clock c1(2, 3, 30);

Everything works just fine, but it keeps giving me this error that says "Expected ';' before 'c1'"

Fine, I put the ';' .. but then, it gives me this error: "'c1' was not declared in this scope"

Here's the whole header code:

#include <iostream>
using namespace std;

class clock
{
private:
 int h;
 int m;
 int s;

public: 
 clock(int hr, int mn, int sec);
};

clock::clock(int hr, int mn, int sec)
{
 h = hr;
 m = mn; 
 s = sec;
}

Here's the whole .cpp code:

#include "clock.h"

int main()
{
    clock c1(2, 3, 30);
    return 0;
}

I stripped everything down to where I had the problem. Everything else, as far as I know, is irrelevant since the problem remains the same with just the mentioned above.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about c++

Related posts about xcode