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


#include <iostream>
#include "a.h"
using namespace std; 

int main() 
	Test *test[1];
	int value = 2;
	test[0] = new Test(); 
	cout << test.getValue(); //Should output 2 to my understanding. 


#include "a.h"
using namespace std; 


void Test::setValue(int inValue)
	value = inValue;

int Test::getValue()
	return value; 


class Test
	void setValue(int inValue);
	int getValue();
	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 ;)


commented: Excellent first post. +7



I'll let someone else criticize your code. Feel too lazy right now.

Member Avatar


firstPerson, that's still not right, because test is an array of pointers. It'd be


To the op: test is an array, which means you have to refer to a specific element. The other catch is that it's an array of pointers, which means you must also dereference it.

commented: Very helpful and friendly. Thanks a bunch. +0

Thanks embooglement. I fixed it shortly after your post. Appreciate it.