classes string print out

I am getting the address to print out but i want it to return the string that it was given any help will be appreciated.


header

1
2
3
4
5
6
7
8
9
10
11
12
13
 #pragma once
#include <iostream>

using namespace std;

class A
{
public:
	static string function1();
	static string function2();
	static string bothfunction();
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "Header.h";


string A::function1(){

	return "starting off in function 1";
}

string A::function2() {
	
	return  "NOW in function 2";
}

string A::bothfunction()
{
	return "finshed with both of the functions";
}


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

using namespace std;



int main()
{
	A obj;

	cout << obj.function1 << endl;
	cout << obj.function2 << endl;
	cout << obj.bothfunction << endl;


	system("pause");
	return 0;
}
Hello rezy3312,

In main lines 12 - 14 obj.function1 is not a function call. What you need is obj.function1(). An easy mistake to make. My compiler will complain when I leave off the "()".

Hope that helps,

Andy
Topic archived. No new replies allowed.