All pastes #936951 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-10 19:14 UTC
rendered paste body
// TMP.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>

using namespace std;


class Adrian
{
public:
	Adrian()
	{
		cout << "Constructor called" << endl;
	}

	string getName()
	{
		return name;
	}

	void setName(string newName)
	{
		name = newName;
	}

private:

	string name;
};


void changeName(Adrian);


int main(int argc, char* argv[])
{
	Adrian one;
	one.setName("Adrian");
	cout << "Name is: " << one.getName() << endl;
	changeName(one);
	cout << "Name is: " << one.getName() << endl;

	cin.get();
	return 0;
}


void changeName(Adrian myClass)
{
	myClass.setName("Test");
	cout << "In changeName() name is: " << myClass.getName() << endl;
}