@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9



Comments:

<0> that a function that needs access to members of a cll***, yet doesn't need to be invoked for a particular object is called a static member function
<1> If they remain private, the only way to change the state of an object is through its public methods.
<2> or friends
<3> yeah, to call a static method, you dont need the instance of a cl***.. you can call directly
<1> It manipulates cl***-level (shared) state, so it's the same concept.
<3> say cl*** A {};, you can call A::MyStaticMetod();
<3> wtwtw, static member functions can operate only on static members. (which will be having the memory allocated before any instance of the cl***).
<3> isn't?
<1> That's correct, DoIt
<3> ty :))
<0> yea but my point is which are the objects, the variables of a cl***, the functions of a cl***, or objects aren't cl*** dependent
<0> ;)
<1> wtwtw: The data members of an object may themselves be objects.
<1> For example...
<0> so a cl*** is an object?
<1> No.



<1> Hang on, typing...
<0> ok
<0> :)
<1> cl*** Foo { std::string bar; public: Foo(std::string init} : bar(init) {} };
<1> That's a cl***.
<3> as Solamente said, an object is the named region. but as your doubt, an object is the instance of the cl*** ( which will contain many objects as its members
<4> a cl*** is a schematic for an object instance
<1> Foo foo("whee!");
<1> foo is an object.
<1> foo contains bar, which is also an object.
<5> a cl*** is a type... an object is an instance of that type... much like int is a type, and int x; x is an instance of int.
<1> I have to stress again the C and C++ definition of "object," which is a named region of memory. No more, no less.
<1> That's a lot simpler that the OO definition of object, which is "an instance of a cl***"
<1> In C++, they may be the same thing.
<3> in simple, suppose you have cl*** A{.....}, and you are creating an object by A myObject; (here myObject is the instance of the cl*** A)
<1> So, int x; is an object, too.
<4> when are they NOT the same thing?
<0> thanks for the explanation, i'm still reading trying to figure it out, but thanks :)
<3> cl*** defnition will not allocate any memory. its for the object of the cl***, which will get memory allocated
<3> wtwtw, are you famliar with structure?
<0> yes
<3> will struct definition allocate memory?
<3> say struct mystuct { int x, y,z; }; <-- will this declaration allocate memory?
<0> no
<6> other than some default privilige differences, struct and cl*** are the same in C++
<3> so, same applies to cl***... they both are same...
<3> do read what Tamama said
<0> how about struct a (int x=7 ...), that will allocate space for x or the cl***?
<0> err
<0> struct
<0> {}/
<1> That's incorrect syntax.
<0> i know
<0> :)
<1> struct a { const int x = 7; };
<1> But a doesn't get initialized until there's an instance.
<3> wtwtw, a structure declaration *will not* allocate any memory...
<1> I mean, x
<1> Or a, either.
<1> a bcd; // Now a.x exists
<5> DoIt it may, if there's a static member...
<3> rdragon, about static members, we already said before i guess
<1> cl*** Foo { static int x; } int Foo::x = 123; // The first time you reference cl*** Foo, x is initialized.
<1> is already initialized, I should say.
<0> thanks for the answers, i'm still a little confused but i'll read the chapter again more carefully. i'll understand it eventually.
<0> thanks again for the answers
<0> have a good day/night
<0> :)
<1> wtwtw: You need a different book
<1> Wait
<0> ok
<1> That's not a tutorial. It's a reference.
<3> hey, i have a doubt. if i have cl*** A{.. } and cl*** B{...}, and i want to create the objects of the cl***es in each other. say object of cl*** B in cl*** A and vice versa, buts it seems not possible if both definition are in the same file. is it possible?
<1> For a tutorial, get "Accelerated C++" by Andrew Koenig & Barbara Moo, who worked with Bjarne when he invented C++
<1> It's a superb tutorial that will get you up to speed very quickly.
<0> thanks :), i'll google it up now
<1> DoIt: cl*** B; cl*** A { B& b; public: A(B& init) : b(init) {} }; cl*** B { };
<1> cl*** B; is called a forward declaration
<1> It states that such a name exists, but does not define it.
<7> You won't be able to store both a B object in A and a A object in B, though.
<1> Right.



<7> One fo them will ahve to be a reference/pointer
<1> Well, yes you can.
<7> You can?
<1> DoIt: cl*** B; cl*** A { B& b; public: A(B& init) : b(init) {} }; cl*** B { A* a };
<1> Why not?
<1> Not that you should.
<7> Well, if B contains a A, which contains a B, which contains a A, which contains a B, which contains a A...
<1> Which is why you shouldn't.
<7> There'd be no end to the memory the object would need.
<1> No.
<1> You're thinking about it wrong.
<1> My construct above works.
<8> Solamente pointers/references work.... actual objects don't
<1> Yes
<7> Well, yes, but you aren't directly storing BOTH objects directly. You'Re using references and pointers.
<1> DrkMatter: Right.
<7> Well then, you can't directly store an "actual" B in A and a A in B. =P
<3> what if both definitions are in differnet files?
<5> that's what #include or forward declarations solve
<3> i asked about actual objects though
<1> You can't do... cl*** B; cl*** A { B b; }
<3> but forward declaration is not able to solve for the actual objects
<5> a pointer/reference is a pointer/reference to an actual object
<5> (once it's initialized, of course)
<1> cl*** B; cl*** A { B& b; public: A(B& init) : b(init) {} }; // this is just as good
<1> You just have to have a B instance to give to A
<1> Or...
<1> cl*** B; cl*** A { B* b; public: A() : b(new B) {} ~A() { delete b; } }; // this works
<3> but how come new operator know the size of B?
<3> awwww
<1> By that point, the compiler has taken care of that. You don't need that at compile time. Just at run time.
<3> my bad.. leave it
<3> yeah... :))
<5> because it would likely be in a source file
<5> no... you can't 'new' a forward declared type...
<1> Did I screw that up?
<1> I thought that worked.
<3> wont that work?
<3> bcoz the compiler only need to bother at the time of A's object creation
<3> right?
<5> it needs to know what size to p*** to operator new
<5> but it's correct, just not as written
<3> rdragon, at compile time?
<5> uh, yes
<3> hmmm. okay
<3> so we cant have friend cl***es mutually exclusive. right?
<5> struct A; struct B{ A* a; B(); }; struct A{ int x; }; B::B():a(new A){}
<5> struct A; struct B{ A* a; B(); }; struct A{ B b; }; B::B():a(new A){}
<5> guess I should have shown that, heh
<3> but it seems, it will work. right?
<5> what I just wrote will work, yes
<3> is it bcoz, we are defining the constructor after A ?
<1> heh.. I was just typing that in the IDE.
<5> DoIt - you need to see the cl*** definition to instanciate it.
<3> so, what about friend cl***? can we have B as friend cl*** in A and vice versa?
<5> yes
<3> actually when i worked on that, i had the problem of forward reference.
<3> okay guys, time to go.... see ya all latter....
<6> hm odd
<0> any suggestions, after i read this book and i hope that i will understand c++ at some level, what should i read to gain more knowledge, or i should just stick to coding like crazy in it :)
<6> deque iterator becomes invalid
<1> wtwtw: Read and code
<1> Let me get you the list of books...
<1> http://www.rudbek.com/books.html
<5> Tamama when?
<0> i'm there
<0> thanks Solamente
<6> rdragon: iterator next=iter+1; deque.erase(iter); iter=next; .. when next was previously deque.end(), it borks
<6> that is, next does not evaluate to deque.end() anymore
<7> Quick question, is there any way to re-initialize the default seed for std::random_shuffle, or is it absolutely necessary to use the RandomNumberGenerator template argument to get truly "random" numbers?
<5> use srand(), no?


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #c++
or
Go to some related logs:

#MissKitten
#chatzone
12frenzy
#mirc
#java
#linux
#MissKitten
joptionpane jtextarea repaint wait
#AllNiteCafe
#java



Home  |  disclaimer  |  contact  |  submit quotes