qualified-id in declaration before '(' token

Write your question here.

hi i am just testing stuff and came across this problem qualified-id in declaration before '(' token
this is a very small code.. i am a class 0 beginner :P
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
main.cpp

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


int main() {
   
    test tc;
    
    cout << "testing output2" <<endl;
cout<<"..................................................................................."<<endl;    


magic mg;

mg.print();


    return 0;
}

................................................................................
 test.cpp


#include "test.h"


test::test() {
    cout<< "i am a constructor"<<endl;
}



test::~test() { // deconstructor have no parameters and no return value no variables.
    cout<<"i am the deconstructor"<<endl;
}

 
 
magic::magic1(){
    
    void magic::print(){
        
        cout<< "regular function"<<endl;
    }
    
}




................................................................................
test.h

#include <iostream>
using namespace std;

#ifndef TEST_H
#define	TEST_H

class test {
public:
    test();
    ~test(); //deconstructor  
private:
};

class magic{
public:
    magic1();
    void print();
private: 
    
};

#endif	


  

thanks
You don't give the line of the error, but line 73 looks wrong, if it's meant to be a constructor, the name must be the same as the class, if it isn't, it needs a return type. You would then also have to change the definition (line 43). Also the term is destructor not deconstructor and you should put include guards at the very start of header files and don't use using namespace std; in header files (outside of header files it's your choice but it's still not a good idea). There's also no need to put access identifiers if you aren't going to put anything after them. Finally, proper indenting of code vastly increases readability.
thanks shadowmouse. very helpful!
Topic archived. No new replies allowed.