class and vectors

Hello, I just started to learn c++ so I don't know much yet, but I wanted to learn about creating classes and vectors.


I'm want to make a class lets say class Numbers. Then a vector called aVector as a private field.


class Numbers{

vector<int> aVector


}

Is that the right way to do it? and what other things should I put in the class?


Is that the right way to do it?

Yes, although you're missing two semicolons.

and what other things should I put in the class?

Depends on what you want the class to be able to do (what exactly is a "Numbers")?
Hi Athar, thanks for the reply,

I want to create a class that can read and write a sample to a stream, I will have to use overloading but I still haven't tackled that and still learning classes and vectors.
Well, a class is (usually) a representation of a real or abstract object type, such as "Person", "File", "AccountManager" or similar. Numbers seems a bit of a misnomer. What is an object of type "Numbers"? What can it do?
Perhaps you're looking for namespaces instead.
You lost me there, sorry I'm a complete newbie when it comes to programming and c++.

Well lets say I changed my class name to "sample" and my vector would have doubles instead of ints.
I also forgot to mention that the program would be given an input with a format:

< "number of elements" : element1(space) element 2(space) ... (space) element n>

This is what I have so far, (I only have bits and bobs on my code)


#include <iostream>
#include <vector>
using namespace std;

class sample
{
double d;
vector<double> sVector;

public:
sample(){}
sample(){

};

ostream & operator<<(ostream& out, const vector<double> & o){
}

istream & operator>>(istream & in, vector<double> & o ){
}

int main(){

return 0;
}

Topic archived. No new replies allowed.