[ create a new paste ] login | about

Link: http://codepad.org/Q7z3wEK2    [ raw code | output | fork ]

C++, pasted on Jun 28:
/* main.cpp */
#include <iostream>
#include "1.h"
#include "2.h"
using namespace std;

int main()
{
	Choge hoge;
	Choge_2 hoge_2;
	hoge.set();

	cout <<"main.cppでは" <<hoge.ret() <<endl;
	hoge_2.display();

	return 0;
}

/* 1.h */
#ifndef _1_H_

#define _1_H_

#include <iostream>
#include "2.h"
using namespace std;

class Choge_2{
public:
	void display();
};

void Choge_2::display()
{
	Choge hoge;
	cout <<"1.hでは" <<hoge.ret() <<endl;
}

#endif

/* 2.h */
#ifndef _2_H_

#define _2_H_

class Choge{
private:
	int hoge;
public:
	void set() { hoge = 5; }
	int ret() { return hoge; }
};

#endif


Output:
1
2
3
4
5
Line 14: error: 1.h: No such file or directory
Line 14: error: 2.h: No such file or directory
In function 'int main()':
Line 9: error: 'Choge' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: