Can't understand the syntax c++

For everyone, just starting with C++ or programming at all. Ask newbie questions in this forum!

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Can't understand the syntax c++

Postby turtail » Fri Oct 09, 2009 7:36 am

I have a problem to understand the following code. Can anybody please help me to understand it.

indication = MediumIndication::IDLE;
catIndication = bb->subscribe(this, mi, getParentModule()->getId());

catRadioState = bb->subscribe(this, cs, getParentModule()->getId());

catDroppedPacket = bb->getCategory(droppedPacket);

Specially, in this "bb->subscribe(this, mi, getParentModule()->getId());" part.

Here 'MediumIndication', is a Class, 'mi', 'cs' are object of a class, 'subcribe' is a function, 'getParentModule()', 'getId()' are functions. droppedPacket is also an object of a class. 'bb' is a pointer to a class. I hope it is now clear to you.

Thanks in advance.
turtail
 
Posts: 1
Joined: Fri Oct 09, 2009 7:30 am

Re: Can't understand the syntax c++

Postby MXP » Mon Oct 12, 2009 4:43 pm

Which part of that line is giving you trouble?
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Re: Can't understand the syntax c++

Postby ss710146 » Tue Oct 13, 2009 12:13 pm

The syntax! The C++! It be too much. Gasp.
ss710146
 
Posts: 1
Joined: Tue Oct 13, 2009 11:53 am

Re: Can't understand the syntax c++

Postby Alvaro » Tue Oct 13, 2009 2:08 pm

There are only five syntactic elements in that piece of code: Assignment operator (=), scope specification(::), dereferencing a pointer and naming one of the members of the object (->), function calls (()), and marking the end of a statement (;). It really isn't that bad... Start by learning the basics of the language from a tutorial. In a forum nobody can answer a request of the type "teach me C++", which is pretty much what you are asking.
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Re: Can't understand the syntax c++

Postby ventsyv » Wed Oct 14, 2009 12:41 pm

As Alvaro said:
; - indicates the end of a statement.
-> and . are (sub)member selection
func1(int x) - function call with 1 parameter, namely integer "x"
User avatar
ventsyv
 
Posts: 2810
Joined: Mon Sep 22, 2003 5:25 pm
Location: MD USA


Return to For Beginners

Who is online

Users browsing this forum: Google [Bot] and 3 guests