|
-
November 3rd, 2008, 09:08 AM
#1
Undeclared identifier..
That's right, I said it. Please don't call me an idiot, but I actually need help with this. My code follows, and it throws a C2065 every reference to i. This really doesn't even belong in this forum, but like I said I'm stumped. Thank you!
driver.cpp:
#include <iostream>
#include "MyClass.h"
using namespace std;
int main() {
MyClass list[3];
int i;
for(i=0; i<3; i++)
list[i].setInt(i+1);
for(i=0; i<3; i++)
cout << list[i].getInt() << "\n";
return 0;
}
MyClass.h:
using namespace std;
class MyClass {
public:
void setInt(int j);
int getInt();
private:
int i;
};
MyClass.cpp:
#include "MyClass.h"
using namespace std;
void setInt(int j) {
i = j;
}
int getInt() {
return i;
}
Last edited by TurkeyMaster77; November 3rd, 2008 at 09:13 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|