So starting to learn C++. I am a pretty decent (not great) Java Programmer and I went to the C++ reference site, but my Partner and I still can’t figure out what
list<int> & testSort(istream & idata, istream & sdata)
means
We got this far
the list object is of type int
testSort is our class
I’m having trouble with the & symbols and the istream data type.
Also, if you can explain what the vector data type is all about that would be appreciated
Well, here’s some stuff to start with:
C++ Reference: This will get you started if you need to look up a standard class type.
C++ FAQ: This will help you if you get REALLY lost. Most of it is edge cases, but some is best practice.
And you already found here, which is possibly the best of all for weird cases.
But as for your specific question, remember that in C++ you don’t need to have your methods in a class. There are “free functions” that are like methods, but don’t belong to any class. So
testSortisn’t a class, or a method of a class, but a stand-alone function, much like a static method on a static class in Java.Also, the
list<>class is more like a linked list, rather than theList<>orArrayListtypes of Java. Thevector<>class is what you want for an array-like class in C++.As for the
&symbol, it means a reference, which you should look up in some basic C++ guides for an explanation of value types vs pointers vs references.The istream types are streams, which I hope you are familiar with from Java. The C++ reference above has more on those in the “IOStream Library” section.
Good luck, and welcome to C/C++!