Source not seeing header?

Hey guys

I've always had this problem, always...

I like to keep my code clean and as such, like to keep my source in source files and declarations and such in my header files, but to all avail, it always fails!

ini_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef INIHANDLER_H
#define INIHANDLER_H

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

class INI
{
	string data;
public:
	// Constructor accepts file pathname as argument
	void INI(string);

	// Returns all data in file
	string rawData(void) { return INI::data; };
};

#endif INIHANDLER_H 


ini_handler.cpp
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
#include "ini_handler.h"
#include "StdAfx.h"
#include <string>

#include <iostream>
#include <fstream>

using namespace std;

// Upon constructing, read file into data value
INI::INI(string fileName)
{
	char *line = new char[100]; // Holds the file's data
	ifstream file;

	file.open(fileName);

	if(file.is_open())
	{
		// Read file contents
		while(!file.eof())
		{
			file.getline(line, 100);
			data += line;
			data += '\n';
		}
	}

	delete[] line;
	file.close();

}


Here's the error code:
1
2
3
4
5
c:\users\zinglish\documents\visual studio 2010\projects\d3d game base\d3d game base\ini_handler.cpp(11): error C2653: 'INI' : is not a class or namespace name
c:\users\zinglish\documents\visual studio 2010\projects\d3d game base\d3d game base\ini_handler.cpp(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\zinglish\documents\visual studio 2010\projects\d3d game base\d3d game base\ini_handler.cpp(24): error C2065: 'data' : undeclared identifier
c:\users\zinglish\documents\visual studio 2010\projects\d3d game base\d3d game base\ini_handler.cpp(25): error C2065: 'data' : undeclared identifier
c:\users\zinglish\documents\visual studio 2010\projects\d3d game base\d3d game base\ini_handler.cpp(32): warning C4508: 'INI' : function should return a value; 'void' return type assumed
closed account (10oTURfi)
Constructor doesnt have void as return value.
void INI(string); should be INI(string);
I have tried that but with the same outcome...i've tried nearly everything
Only two things I can recommend:

1. Put your project head after all standard headers, including stdafx.
2. Make a default constructor.
INI::INI()
{
}
Thank you :)

Solved by putting my header include AFTER stdafx
Topic archived. No new replies allowed.