My getter functions don't print variables???

So I've have trying to get this to work, but is seems like Visual Studio 15 doesn't like me today.

The code is really simple, yet it only prints the rule that comes with system("PAUSE"). How can I print the variable, getName() returns without using cout << string;?

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
  // Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class pokemon {
private:
	string name;
public:
	string getName() {
		return name;
	}
	void setName(string newname) {
		name = newname;
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	pokemon hoi;
	hoi.setName("Pickachu");
	hoi.getName();

	system("PAUSE");
	return 0;
}


getName() doesn't print anything. It just returns the string value. If you want to print the string you should use cout.
Topic archived. No new replies allowed.