Edit. Compiler errors. Code Blocks

For some strange unknown reason i get an error in my codeblocks when trying to run this. it's in my coins.cpp it give me a fatal error coins.h no such file or directory. Now in my main.cpp i have to type my coins.h the way i did to get rid of the error for that, however even if i type the code like that in coins.cpp i still get the fatal error, what am i doing wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  //main.cpp
   #include <iostream>
#include "include\coins.h"

using namespace std;

void training_grounds(), tutorial(), town();

int main()
{

    coins test;

    test.coinValue();


1
2
3
4
5
6
7
8
9
10
11
12
13
14
//coins.h
#ifndef COINS_H
#define COINS_H



class coins
{
    public:
        coins();
    int coinValue();
};

#endif // COINS_H 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//coins.cpp
#include "coins.h"
#include <iostream>


using namespace std;


coins::coins()
{

}

int coins::coinValue(int a)

{

    a = 2;
    cout << a;
    return a;

}
Last edited on

You declare a member function int coinValue() in your class but the function at line 14 in coins.cpp is declared as accepting an integer:

int coins::coinValue(int a)
I figured it out, code blocks was creating the class wrong had to change a few settings thanks.
No problem, glad you sorted it.
Sorry not fixed new problem,
I'm getting the error undefined reference to WinMain@16
What does that mean?

Have you created a console project, sounds like you may have created a incorrect project type, or you have a brace somewhere you shouldnt, or main is missing lol.. could be a lot of things.

post your code.
Last edited on
Topic archived. No new replies allowed.