Hello,
I used to code in python and I recall being able to take a class such as the list class and add my own functions to it. I am not quite sure what this is called in c++ or how to do it, so I was just wondering if some one could point me in the right direction with an article, tutorial, or at least what it is called for C++.

Thank you
~Blitze

Sounds like you want to research Inheritance.

I can't seem to find an article that displays the syntax for adding functions to a std class in c++ such as an array or vector... is there a way to do that?

Im not actually sure if you can inherit from the std library, but if you were able to,

class MyClass : public vector
{
}

The colon is the inheritance operator, but like i said, Im not sure if you are able to inherit and how it works with templated classes. Essentially, all the vector class is, is a linked list. You could build a class that can do what the vector can do and more fairly easily if you know how to handle pointers.

http://www.cprogramming.com/tutorial/lesson19.html
there is a second part after the first page that helps explain with a syntax example.

>>all the vector class is, is a linked list
Are you implying that a std::vector class is implemented using a linked list data structure?

Example :

template<typename T>
class SpecialList : std::list<T>{
public:
 //add functionalities here
};

Or use composition :

class SpecialList{
 private: std::list<int> listOfInts;
 public: 
  void push_back(int i){ listOfInts.push_back(i); }
  //..more list functions, delegate the job to list;
  //add your functionalities here.
};

Ive never opened up and took a look at the header file, but the functionality it provides, seems very similar to a linked list data structure. I could be wrong, but that's sort of how I see it.

Yea, sorry to tell you but std::vector is based on arrays not linked list. It provides those functionalities to be consistent.

Alright, I will look into it. Thank you all for the suggestions, I appreciate it. I will be attempting to do it over the weekend so I'm not sure how it will go just yet..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.