473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

public function calls

I want to know the difference between the following 3 methods of
calling a public function, which method is better and why

method 1:

myClass::myFunction();
method 2:
myClass myObject;
myObject.myFunction();

method 3:
myClass * pMyObject;
pMyObject->myFunction();

I know the difference between 2 and 3, but i'd like to know the
differences between 1 and the others

BlueDoze
Jul 19 '05 #1
3 8856
BlueDoze escribió:
method 1:

myClass::myFunction();


You call this way when myFunction is a static member function of
myClass.

Regards.
Jul 19 '05 #2
> method 3:
myClass * pMyObject;
pMyObject->myFunction();


and method 3 is generally used for polymorphism ; if pMyObject points to a
derived class of myClass and if myClass declares virtual functions, then you
get polymorphism
Jul 19 '05 #3

"BlueDoze" <bl******@yahoo.com> wrote in message
news:a5**************************@posting.google.c om...
I want to know the difference between the following 3 methods of
calling a public function, which method is better and why

method 1:

myClass::myFunction();
method 2:
myClass myObject;
myObject.myFunction();

method 3:
myClass * pMyObject;
pMyObject->myFunction();

I know the difference between 2 and 3, but i'd like to know the
differences between 1 and the others


Method 1 would be used in 3 cases:
a) myFunction is a static function, being called from somewhere outside
myClass
b) it's a function of the base class, where it's being called from a derived
class of myClass
c) it's a member function being called from another function of myClass.

In the case of c) it's not necessary to prefix with myClass - in fact it
would be redundant and confusing.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rl | last post by:
Hi out there, I'd like to know sth about the costs of a function call in php and the handling of character arrays (init size, enlargement steps of allocated memory, technique on enlargement ->...
10
by: Michael | last post by:
Guys, I'm interested in how the compiler implements function calls, can anyone correct my understanding/point me towards some good articles. When a function is called, is the stack pointer...
4
by: atv | last post by:
Whatis the proper way to handle errors from function calls? For example, i normally have a main function, with calls to mine or c functions. Should i check for errors in the functions called...
10
by: Nitin | last post by:
Ppl , Want to have ur opinions on having function calls like the one stated below: function funcA ( struct A *st_A , struct B *st_B ) { st_A->a = st_B->a
6
by: pakis | last post by:
I am having a problem of pure virtual function call in my project. Can anyone explaine me the causes of pure virtual function calls other than calling a virtual function in base class? Thanks
1
by: Lee Harr | last post by:
I have a view like this: CREATE or replace VIEW program_member_this_year AS SELECT DISTINCT person.person_id FROM unit.person, unit.visit WHERE unit.person.person_id = unit.visit.person_id...
7
by: alexander.stippler | last post by:
Hi I wonder if their will be a performance penalty in the following situation due to virtual function calls: class Interface { public: virtual void methodA() = 0; virtual void methodB() =...
6
by: Dasn | last post by:
Hi, there. 'lines' is a large list of strings each of which is seperated by '\t' I wanna split each string into a list. For speed, using map() instead of 'for' loop. 'map(str.split, lines)'...
16
by: Xiaoxiao | last post by:
Hi, I got a C library, is there a way to view the public function names in this library so that I can use in my C program? Thanks.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.