Object not declared in scope
- by jay
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!