C++ Classes

Mar 13, 2013 at 1:03pm
Dear all,

First of all, I am so happy to join this forum.
I am a C++ beginner learner. I have learned the basics and still unable to understand some programs certainly with complicated classes, for example, I am unable to understand this statements:

APP::APP()
:PAP("P C A")
{
setIP(TS::instance()->pointer()->tip());
setOR(F::instance()->refPtr());
setHI("I:PP.png");
connect(this, SIGNAL(sigPA(const LP&)),
F::instance(), SLOT(setPC(const LP&)));
}

Could you please give some links or book titles where I can learn the complicated classes by example?

Could you also help me to understand this code?

Thank you in advance for your response.
Mar 13, 2013 at 3:28pm
I'm a beginner myself and learning about classes as well. I recognize the format but its very hard to read, it looks like because of the variable names and strings.
Last edited on Mar 13, 2013 at 5:11pm
Mar 13, 2013 at 3:38pm
This isn't really complicated. I'm sure it's just some of the symbols giving you trouble.

APP::APP() This double colon here is a scope resolution operator. It tells the compiler where this method belongs, namely the APP class. You'll see this whenever class implementation is separate from definition.

1
2
APP::APP()
:PAP("P C A")
Following the method header and the single colon is what's called an initialization list. PAP is likely the super class to APP, this is just a way of calling the super class constructor.

1
2
setIP(TS::instance()->pointer()->tip());
setOR(F::instance()->refPtr());

These are similar to each other. Basically, it's calling methods from the TS class and F class respectively, using the scope resolution operator. The -> you see is just a shorthand to dereference a pointer to an object and then call a method or field from that object. In this example, setIP() takes one argument, that is returned by TS::instance()->pointer()->tip().
Mar 14, 2013 at 9:08am
charleette and ResidentBiscuit, thank you for your replies.
ResidentBiscuit, do you have an idea where I can learn all these symbols or rather the complicated classes, a book name or a site link may be?

Thank you in advance for your response.
Mar 14, 2013 at 10:57am
http://www.cplusplus.com/doc/tutorial/classes/

look at Classes (I) page, Classes(II) page, and section "What is inherited from the base class?" from Friendship and Inheritence page.
Mar 14, 2013 at 12:04pm
Thank you, I will read this tutorial
Mar 14, 2013 at 1:44pm
and:
1
2
setIP(TS::instance()->pointer()->tip());
setOR(F::instance()->refPtr());


suggest to me that TS and F might be singleton classes:
http://forums.codeguru.com/showthread.php?344782-C-Design-Pattern-What-is-a-Singleton-class

which are generally bad to use in my opinion.

Mar 14, 2013 at 1:57pm
Nothing necessarily wrong with a singleton. They have their uses. But OP isn't going to know what those are right now anyways.
Mar 14, 2013 at 3:13pm
in my opinion


:)
Mar 14, 2013 at 5:37pm
Thank you all for your replies. I will try to read all the suggested sources and then come back to see if I can understand this code.
Anyway, if you have any other clarifications, I will be so grateful.

C U soon,

Best regards
Topic archived. No new replies allowed.