473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

class inher : private vector<option *>

38
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5.  
  6. class option
  7. {
  8.  
  9. };
  10.  
  11.  
  12. class inher : private vector<option *>
  13. {
  14.             public :
  15.  
  16.             void push_back(option * a)
  17.             {
  18.                 vector<option *>::push_back(a);
  19.             }
  20. };
  21.  
  22. int main(void)
  23. {
  24.  
  25.  
  26. return 0;
  27. }
This code compiles successfully.
My , questions are:

1)Can any body explain the meaning of the statement "class inher : private vector<option *>"

2)Which function gets called in the statement , or can you explain the meaning of the statement given below.
" vector< option * > :: push_back(a); "
May 15 '07 #1
3 1543
svlsr2000
181 Expert 100+
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5.  
  6. class option
  7. {
  8.  
  9. };
  10.  
  11.  
  12. class inher : private vector<option *>
  13. {
  14. public :
  15.  
  16. void push_back(option * a)
  17. {
  18. vector<option *>::push_back(a);
  19. }
  20. };
  21.  
  22. int main(void)
  23. {
  24.  
  25.  
  26. return 0;
  27. }
This code compiles successfully.
My , questions are:

1)Can any body explain the meaning of the statement "class inher : private vector<option *>"

2)Which function gets called in the statement , or can you explain the meaning of the statement given below.
" vector< option * > :: push_back(a); "
Your class inher is inheriting from c++ stl vector class.
Have a look at http://www.yolinux.com/TUTORIALS/Lin...TL.html#VECTOR
for exploring more about vector
May 15 '07 #2
gpraghuram
1,275 Expert 1GB
HI,
Answer to the second question
2)Which function gets called in the statement , or can you explain the meaning of the statement given below.
" vector< option * > :: push_back(a); "

---->The push_back is the method available with the vector container.

As explained by the svlsr you can take a look at the vector reference for more info.

Raghuram
May 15 '07 #3
AdrianH
1,251 Expert 1GB
Your class inher is inheriting from c++ stl vector class.
Have a look at http://www.yolinux.com/TUTORIALS/Lin...TL.html#VECTOR
for exploring more about vector
To be more specific, it is privately inheriting from vector (this is called implementation inheritance). The introduced push_back() method is to allow a user of the class access to that method of the vector class (it could have been named anything you wish, the writer just happened to name it with the same name and signature).


Adrian
May 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Marc Schellens | last post by:
my dinkumware docu says, vector<...>::rbegin() returns an iterator which points just BEYOND the end of the controlled sequence. Is that true? so I cannot say: for( riter i=v.rbegin(); i !=...
2
by: john smith | last post by:
Hi, when there is a vector<> of pointers to some objects, does calling resize cause vector to call delete on each object, or is there a memory leak problem? for example: struct base {//some...
10
by: Stefan Höhne | last post by:
Hi, as I recon, std::vector::clear()'s semantics changed from MS VC++ 6.0 to MS' DOT.NET - compiler. In the 6.0 version the capacity() of the vector did not change with the call to...
6
by: Joe | last post by:
I have a: vector<string> which contains a few dozen elements. I want to find the index of the element containing a certain string. for example: vector<string> strings;...
3
by: Dean L. Howen | last post by:
Hi friends, In C++, we can declare a struct and write it into file just by giving the address the strct instance (using &). for example: ///////////////////////////////// typedef struct Test...
5
by: Numeromancer | last post by:
From the C++-FAQ Lite: http://www.parashift.com/c++-faq-lite/containers.html#faq-34.3 ---------------------------- 34.3] Is the storage for a std::vector<Tguaranteed to be contiguous? Yes. ...
8
by: jacek.dziedzic | last post by:
Hi! I need to be able to track memory usage in a medium-sized application I'm developing. The only significant (memory-wise) non- local objects are of two types -- std::vector<and of a custom...
3
by: Rune Allnor | last post by:
Hi folks. I have a function that takes an element in a vector as argument. The naive interface goes as float computeSomething(const std::vector<float>& v, size_t i) { size_t j = i-1; size_t...
4
by: iammilind | last post by:
I am not able to understand why the 2nd ~Test() is called with different 'this' but the same string value ?? Also why does it give error, if I want to declare Test::Str as a const string member ?? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.