lego69
lego69

Reputation: 857

an error "variable of field declared void"

I have this code:

header - test.h

Inside header I have some class A and definitions of two functions quiz and quiz2

void quiz(int i);

void quiz2(A a, A const *pa);

I call function quiz2 from quiz

A a1(i);
A *pa1 = new A(a1);
quiz2(a1, pa1);

this is implementation of the function:

  void quiz2(A a, A const *pa){
        int i = a;
        cout << i << endl;
}

but in my header I receive 3 errors near the line of definition of quiz2:

Multiple markers at this line
    - initializer expression list treated as compound 
     expression
    - `A' was not declared in this scope
    - variable or field `quiz2' declared void

can somebody please explain why? thanks in advance

Upvotes: 0

Views: 3009

Answers (1)

lego69
lego69

Reputation: 857

I forgot that I must declare firstly classes and only after that functions, so now it's working

Upvotes: 1

Related Questions