function non-class type ???

My g++ compiler is telling me that said printTest() is not part of the class. I have presented it in header class and implemented it in .cpp class but still keep getting the error. Any help would be awesome.

Compile and compile error -

blackjack > g++ -Wextra -pedantic -std=c++11 Deck.h Deck.cpp test.cpp ;
test.cpp: In function ‘int main()’:
test.cpp:6:6: error: request for member ‘printTest’ in ‘test’, which is of non-class type ‘Deck()’
test.printTest();

My Code -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Deck.h
#include <iostream>
#include <string>

class Deck{
	public:
		Deck();
		void printTest();
};


//Deck.cpp
#include <iostream>
#include "Deck.h"

using namespace std;

Deck::Deck(){
}

void Deck::printTest(){
	cout << "this is a deck test" << endl;
}

//test.cpp
#include <iostream>
#include "Deck.h"

int main(){
Deck test();
test.printTest();

}

Deck test;
Try
Deck test;
instead of
Deck test();
That was it, thank you very much. I have another class that works the same way but the constructor takes params so - Card card(1,3) worked just fine. I would of never thought this to be the problem. I have been going back and forth analyzing everything for the last hour. Thanks again.
Topic archived. No new replies allowed.