Thread: change the value of a variable of an object that is in a vector of objects in a class

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    1

    change the value of a variable of an object that is in a vector of objects in a class

    Hi,
    I'm getting way out of my regular field to do this and I've been running into some stupidly complex situations.
    I've declared a class which has a variable "int activacion" and then I've made another class which has a vector of objects of this previous type.
    Then I've done another class which has a vector of the lattest.
    I'd find it completely normal if I just couldn't go on but the thing is I'm not having trouble READING the values using getValue(), and I just can't seem to be able to change it using the same line of code with setValue();


    getElementoVectorCapas(i).getElementoVectorNeurona s(j).getActivacion()<<endl;
    This works.


    getElementoVectorCapas(1).getElementoVectorNeurona s(0).setActivacion(1);
    This doesn't.
    It's like the value is fixed. It compiles allright, it just does not change the value.
    Thanks in advance.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    It sounds like your design is really messed up - post some more code
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I can't even tell in what context code such as the above has been made to compile. It looks somewhat like nonsense to me.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    It could be simply that the class set method doesn't work. Try to use a debugging tool?
    Check out my programming / algorithm blog @ http://www.swageroo.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change the Date for all objects of a class
    By ShadowDragon in forum C++ Programming
    Replies: 4
    Last Post: 12-07-2011, 05:28 PM
  2. Vector of pointers to vector of objects
    By Litz in forum C++ Programming
    Replies: 10
    Last Post: 11-06-2009, 03:29 PM
  3. Replies: 10
    Last Post: 05-22-2009, 11:12 PM
  4. Replies: 4
    Last Post: 10-16-2003, 11:26 AM
  5. Replies: 3
    Last Post: 02-12-2002, 10:09 PM

Tags for this Thread