Public feed #892889

Untitled

public cpp v1 · immutable
Raw Edit
·published 2008-02-05 19:19 UTC
rendered paste body
#include <iostream>#include <string>using namespace std;int main(){	string *var = new string;	*var = "blah";	// can't do var = "blah"; ?	// Why can't i alter var directly?	cout << "var  = " << var  << "\n"; // Looks like a memory address	cout << "*var = " << *var << "\n"; // Is blah, this bit seems ok.	cout << "&var = " << &var << "\n"; // Also looks like a memory address, but a different one to var?	// whats the difference between var and &var if they are both memory addresses?	// Is this a silly way of setting vars and their pointers?	// Using this declaration method, how can i edit var directly instead of through the pointer?	cin.get();	return 1;}