I am entering a string for the class. How do I get set the values for that string permanently? For example, I want to set it like how I would through references, but how would I even begin doing that using a string through class?
// The Learning Process.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
typedefshortint UINT;
class jimboClass
{
public:
std::string myString;//i want this to be set to whatever user types
};
void printString()
{
jimboClass objectPrintString;
std::cout << "From printString(): " << objectPrintString.myString << std::endl; //this line prints nothing, but i want it to print the same thing as jimboObject.myString
}
int main()
{
jimboClass jimboObject;
std::getline(std::cin, jimboObject.myString);
std::cout << "From main(): " << jimboObject.myString << std::endl;
printString();
return 0;
}
How do I get set the values for that string permanently?
This sounds to me like the OP wants a static final class member, but I have to agree with you after seeing your examples that the OP is trying to accomplish something else.