How to use additional Header and Implementation files in a project that already has a 'header-imp-class' configuration.

I have a project in which I have a normal c++ file for my main function and I have a header for declaring a class with its member functions and fields, and I have another regular c++ file to implement the class (define its member functions and fields).

I now want to make yet another header and implementation file in the same project; in these files I want to declare and define void functions which take an object belonging to my created class as an argument; then I want to call those void functions to main.

I'm missing something in the second header file containing the definitions of the void functions as I get an error pointing to the function definition, but I can't understand the message.

Here's the code. It works fine if I just put it all in the main c++ file, just not like this. Note, header file 'House.h' included in 'Header.h' is the header with the declaration of the class, as far as I'm aware both headers need to be included in each other for the system to work, as well as both headers being included in the main file as well as each header files being included in
their respective implementation c++ files.
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

#ifndef HEADER_H
#define HEADER_H

#include "House.h"
void print_house_data(const House& house);

#endif

---------------IMPLEMENTION FILE OF THE VIOD FUNCTION------------

#include "Header.h"

#include<iostream>
using namespace std;

void print_house_data(const House& house) {

	cout << "The house has " << house.getnumstories() << "stories, with  " << house.getnumwindows() <<
		"windows, and is the colour " << house.getcolor() << endl << endl;

}

---------ERROR MESSAGES------------

Severity	Code	Description	Project	File	Line	Suppression State

Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	classes true example	C:\Users\User\Desktop\saved cpp files\classes true example\classes true example\Header.h	5	

Error	C2143	syntax error: missing ',' before '&'	classes true example	C:\Users\User\Desktop\saved cpp files\classes true example\classes true example\Header.h	5	

Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	classes true example	C:\Users\User\Desktop\saved cpp files\classes true example\classes true example\Header.h	5	

Error	C2143	syntax error: missing ',' before '&'	classes true example	C:\Users\User\Desktop\saved cpp files\classes true example\classes true example\Header.h	5	
Last edited on
show your code. Compile with warnings turned on.

Post the errors verbatim.
Last edited on
Does the another header/implementation have an include for the used class header?
Have edited to show the code more fully.
What is in the House.h?
Topic archived. No new replies allowed.