@
BlackDahlia1147
I think you misunderstand what I said.
95 96 97 98 99
|
while (inFile.peek() != EOF)
{
charShift(inFile, letter, line, index);
cout << letter;
}
|
Line 97 doesn't assign the value returned by the function
charShift
. The value of the variable
letter
on line 98 is not changed. You could do one of these instead :
1.
cout << charShift(inFile, letter, line, index);
2. Make
charShift
a void function, but send it a reference or pointer to the letter variable. That way the value of the letter variable in main() will be changed, and you won't need to change lines 97 &98.
BlackDahlia1147 wrote: |
---|
And yes, this is for a class and i dont know any methods for coding besides what i have used here. Never heard of the STL algorithms or really any algorithms in coding :/ |
That is fine for now, if you are interested there is a wealth of info in the reference section (including examples) & a tutorial in the documentation section.
Scott Meyers (An author of some really good C++ books) describes C++ as a federation of 4 languages:
1. C with it's basic data types int, double, char, pointers etc. and flow control - if-else-if-else, loops, switch etc;
2. C++ with it's classes, Object Oriented - polymorhism, inheritance etc, function & operator overloading plus much more;
3. Template C++ - generic programming,
this allows (really basically) one to write a function once that will work with a multitude of types . E.g std::abs
works for any type int, doubles, floats. C has a different function for each of these ;
4. STL - Standard Template Library. This has containers like string, vector, list, map etc. They have constructors and member functions, overloaded operators, and one can use algorithms like
std::find
on them.
I am not quoting him directly here, just the 4 items, I put my own very brief & incomplete descriptions.
Hope this helps a bit.
Edit: I stuffed up item number 3 - that is function overloading. Better off with a link to describe them :