C++ Classes

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.
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
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().
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.
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.
Thank you, I will read this tutorial
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.

Nothing necessarily wrong with a singleton. They have their uses. But OP isn't going to know what those are right now anyways.
in my opinion


:)
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.