Problem with "not declared in this scope" error
- by lego69
I've got:
error a1 was not declared in this scope
Can somebody please explain why this code causes that?
quiz.h
#ifndef QUIZ_H_
#define QUIZ_H_
#include "quiz.cpp"
class A {
private:
int player;
public:
A(int initPlayer);
~A();
void foo();
};
#endif /* QUIZ_H_ */
quiz.cpp
#include "quiz.h"
#include <iostream>
using std::cout;
using std::endl;
A::A(int initPlayer = 0){
player = initPlayer;
}
A::~A(){
}
void A::foo(){
cout << player;
}
main function
#include "quiz.h"
int main()
{
quiz(7);
return 0;
}
quiz function
#include "quiz.h"
void quiz(int i)
{
A a1(i);
a1.foo();
}