LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-04-2012, 01:23 PM   #1
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Rep: Reputation: 15
Vector in a Vector C++


All,

Is there anything wrong with having a vector within a vector?

I know I need a modified copy and delete constructor. Plus it would need an overrided =operator. Is there anything else I would need?

Code:
typedef class myV2
{
   public: 

      myV2()
      
      int expV1a;
      int expV2a;
      int expV3a;
}

typedef class myV1
{
   public: 

      myV1()
      
      int expV1;
      int expV2;
      int expV3;
      vector<myV2> v2;
}

vector<myV1> v1
 
Old 11-04-2012, 01:47 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by gothrog View Post
Is there anything wrong with having a vector within a vector?
No.

Quote:
I know I need a modified copy and delete constructor. Plus it would need an overrided =operator.
Why do you think you need any of those things?

Your classes might need modified (vs. the default provided by the language) constructors or destructors or operator= etc., but not because of having a vector within a vector and not because of anything you showed in your sample code.

Also:

1) Get rid of the keyword typedef when declaring each of your classes. This is C++, not C.

2) If you are just declaring those constructors (to be defined later) put a ; at the end of each such declaration. If you are defining them, you need {}

3) You need a ; after the } ending each class definition.

Last edited by johnsfine; 11-04-2012 at 02:02 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] vector,matrices drawing software. some thing like android(Visual Vector Math) PoleStar Linux - Newbie 3 11-02-2012 10:45 PM
LXer: Tropic of Vector – a blog devoted to Vector Linux Light, plus the Vector Linux LXer Syndicated Linux News 0 09-17-2009 01:30 PM
c++ vector ::size() nonzero before putting anything in the vector - ?! map250r Programming 21 01-10-2009 02:27 PM
LXer: Vector Linux 5.9-Pseudo64-0.1 -- Finally, 64-bit Vector LXer Syndicated Linux News 0 09-12-2007 01:20 PM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 08:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration