This is my first post here on Daniweb and I intend to do things right. I actually did read the "READ THIS FIRST" thread and instead of posting 500 lines of code I whipped up a test program I aptly titled test.cpp
First I will walk you through my problem. The overall purpose is irrelevant but I am trying to create an array of pointers that point to different instances of objects that I created from my own class. For the purpose of the test I called my class test. I then want to set multiple values to my objects and then have them return these values to the screen. I have done this in three files: test.cpp, a.cpp, a.h
test.cpp
#include <iostream>
#include "a.h"
using namespace std;
int main()
{
Test *test[1];
int value = 2;
test[0] = new Test();
test.setValue(value);
cout << test.getValue(); //Should output 2 to my understanding.
}
a.cpp
#include "a.h"
using namespace std;
Test::Test()
{
}
void Test::setValue(int inValue)
{
value = inValue;
}
int Test::getValue()
{
return value;
}
a.h
class Test
{
public:
Test();
void setValue(int inValue);
int getValue();
private:
int value;
};
When compiling these I get the error:
/Programming Projects/CSCI211/Project 2/Calendar/test/main.cpp:12:0 /Programming Projects/CSCI211/Project 2/Calendar/test/main.cpp:12: error: request for member 'setValue' in 'test', which is of non-class type 'Test* [1]'
Honestly I am not in that big of a rush right now. I have been programming most of the last two days and I am ready for a break. It is probably the fact that I have been working on this for a while that I can't see the problem.
Anyway, any and all help, suggestions and criticism would be welcome with open arms ;)
Cheers,
Takeshi91k