The universe is telling you that you picked the wrong language. Next up: python.
Type: Posts; User: 7stud
The universe is telling you that you picked the wrong language. Next up: python.
When you create a struct, you create a new type--just like int, double, float, etc. The new type is the name of the struct. Your vector has to declare what type of things it will contain. 'struct'...
Ok, now apply that same logic to this code:
string myStringErrors;
...
std::getline(file,myStringErrors)
...
const char* myStringNoSpaces = myStringErrors;
string str(myStringNoSpaces);...
struct is a C++ keyword, it is not a type. Vectors must specify the type of the thing they hold. What type of things is your vector going to hold?
Well suppose your code did this:
int num = 10;
int irrelevant = num;
num = irrelevant;
What would you do to make that code more efficient?
Whenever you ask a question about an error, ALWAYS post a message on the line that has the error, like this:
int n = 10.5; //***ERROR***
Or, post the error message along with the line of...
That's up to you to decide:
const char* cstr = "hello world goodbye world";
string str(cstr); //cstring-->c++ string
istringstream input(str); //creates a container called 'input', which ...
Thanks.
Go Advanced/click on "Disable Smilies in text" located below the textarea you type in.
What about:
cin.ignore(cin.rdbuf()->in_avail() );
vs.
cin.ignore(numeric_limits<streamsize>::max(), '\n');
That's what virtual functions are for: you store everything in base class variables and then let polymorphism do its thing(i.e. call different transpose() functions depending on the type of the...
1) A derived type can be assigned to a variable of type base. That's because a base variable can be used to call all public functions and member variables in the base class. Since a derived...
You don't compile .h files, you include them. Then the compiler will replace the include statement with the contents of the specified file. If the file contains only declarations of classes,...
You know this is a C++ forum, right?
1) There's no such type as String or STring or strinG or striNG or strIng or sTrInG.
2) The simplest way to add elements to a vector is by using a vector's push_back() method. There is also a...
All arrays are required to have sizes, so there is no such thing as an "unsized array".
Why not?
You don't declare structs or classes inside main(). You do it outside main(). Likewise, you don't declare that sad, lonely char outside main--you do it inside main().
Next time when you have...
You should never want to create a dynamic anything. If you are forced to, e.g. when you want to create an array that is based on the size of some user input, then you have to take care of deleting...
I don't think that is correct. I think c_str() is guaranteed to return you a cstyle string with a terminating '\0' regardless of what is stored internally in the string object. I haven't dug up the...
I think you must be talking about these lines:
33: void SetUpperLeft(Point Location) {itsUpperLeft = Location;}
34: void SetLowerLeft(Point Location) {itsLowerLeft = Location;}...
Wow. Nice post. <retreats out of the forum backwards, repeatedly bowing low to the ground>
Too ugly. All you need to do is copy the characters in the const cstring to the location of a non-constant variable you declare. You can use strcpy() if you want, or you can use this elegant...
Hi,
As you learned earlier, classes can contain data. For instance,
class Data
{
public:
Data(int n, double d) //constructor function
{
num = n;
double d;
Your teacher made a mistake. You can write:
throw "some string";
A simple example wouldn't involve creating and throwing an exception object(have you even studied objects yet?) Here is what a...