LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-17-2005, 01:25 PM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
point / STL vector, change element question


ok, i have a STL vector of type cadElement, where cadElement is a struct...

Code:
struct cadElement{
  int cad_type;
  int cad_pick;
  double cad_x;
  double cad_y;
  double cad_z;
  double cad_r;
  double cad_g;
  double cad_b;
  double cad_zoom;
};
vector<cadElement> elements;
how can i change a value of one of the elements in the vector??
Code:
((cadElement)elements.at(1)).cad_x=x;
does not work, it will not change the value in the actual vector...
 
Old 09-17-2005, 01:46 PM   #2
Hivemind
Member
 
Registered: Sep 2004
Posts: 273

Rep: Reputation: 30
You could use the subscript operator:
Code:
elements[0].cad_x = x;
Just make sure there's actually an instance of the struct at the given index.
 
  


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
question abt STL algorithim 'difference' irfanhab Programming 2 07-30-2005 09:38 PM
Can't change mount point. RoaCh Of DisCor SUSE / openSUSE 9 05-09-2005 01:51 PM
XML question multiple parents for child element pld Programming 1 03-17-2005 02:14 PM
STL vector of 3 doubles? true_atlantis Programming 2 04-22-2004 10:13 AM
Vector(STL) question(push_back & erase) Ohmu Programming 1 01-29-2004 04:50 PM

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

All times are GMT -5. The time now is 02:54 PM.

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