473,769 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference Between List x; and List x(); , if 'List' is a Class?

I have declared a class with name List;
and in main() function, i have declared the List object as follows
class List
{
public:
List()
{
cout<<"In List Constuctor";
}
};
int main(int argc, char* argv[])
{
List x1;
List x2();
}

Could anybody let me know, What is the difference between "List x1;"
and "List x2();" ?

Thanks in advance.
Jul 22 '05 #1
6 3232

"roopa" <ro***@googley. com> wrote in message
I have declared a class with name List;
and in main() function, i have declared the List object as follows
class List
{
public:
List()
{
cout<<"In List Constuctor";
}
};
int main(int argc, char* argv[])
{
List x1;
This is an object of class List.
List x2();
This declares a function x2 which takes no parameters and returns a List
object. The rule in C++ is that whatsoever can be parsed as a function
declarartion is done so.
}


-Sharad
Jul 22 '05 #2

"roopa" <ro***@googley. com> wrote in message news:ba******** *************** ***@posting.goo gle.com...
I have declared a class with name List;
and in main() function, i have declared the List object as follows
class List
{
public:
List()
{
cout<<"In List Constuctor";
}
};
int main(int argc, char* argv[])
{
List x1;
List x2();
}

Could anybody let me know, What is the difference between "List x1;"
and "List x2();" ?

Thanks in advance.


See relevant discussion at
http://groups.google.com/groups?thre...oh.olympus.net

--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jul 22 '05 #3

"roopa" <ro***@googley. com> wrote in message
news:ba******** *************** ***@posting.goo gle.com...
Re: Difference Between List x; and List x(); , if 'List' is a Class?
For this issue it makes no difference what the type of 'List' is.
I have declared a class with name List;
and in main() function, i have declared the List object as follows
class List
{
public:
List()
{
cout<<"In List Constuctor";
}
};
int main(int argc, char* argv[])
{
List x1;
List x2();
}

Could anybody let me know, What is the difference between "List x1;"
and "List x2();" ?


List x1;
/* creates object of type 'List', named 'x1'. */

List x2();
/* Declares (but doesn't define) a function nameed 'x2',
that takes no arguments and returns a value of type 'List'. */

You should get a 'missing function' error at link time.

-Mike
Jul 22 '05 #4
> You should get a 'missing function' error at link time.

No you won't.

Stephen Howe
Jul 22 '05 #5
Mike Wahler wrote:
...
Could anybody let me know, What is the difference between "List x1;"
and "List x2();" ?


List x1;
/* creates object of type 'List', named 'x1'. */

List x2();
/* Declares (but doesn't define) a function nameed 'x2',
that takes no arguments and returns a value of type 'List'. */

You should get a 'missing function' error at link time.
...


Only if you actually try to call the function.

--
Best regards,
Andrey Tarasevich
Jul 22 '05 #6
ro***@googley.c om (roopa) wrote in message news:<ba******* *************** ****@posting.go ogle.com>...

[ ... ]
Could anybody let me know, What is the difference between "List x1;"
and "List x2();" ?


A better question would be: "is there any real similiarity between the
two", to which the answer would be a barely qualified "No."

"List x1;" defines a List object named x1. "List x2();" declares a
function named x2 that takes no parameters and returns a List.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #7

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

Similar topics

1
4250
by: G. Smith Q news | last post by:
What is the difference between an abstract class and an Interface. As a novice, they both seem to serve the same purpose?
18
6956
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I guess I'll try to narrow it down to a few specific questions, but any further input offered on the subject is greatly appreciated: 1. Are all of my class's methods supposed to take 'self' as their first arg? 2. Am I then supposed to call...
2
2028
by: hong Yu | last post by:
I am new to python. I was confused: >>> a = list('hello') >>> a I want to combine the items in the list into a string. So:
13
31252
by: Murat Ozgur | last post by:
Hello, Is there any difference between ArrayList and List<object? Which one should I use ? Thanks.
2
11959
by: lincoln rutledge | last post by:
I'm having trouble figuring out the difference between a string and a list. I know that: string = "foo bar" is a list of characters, "foo bar", and string is "f". while:
9
6998
by: Stephan Steiner | last post by:
Hi I seem to have a bit of trouble understanding one bit of how generics work: In C#, every class automatically derives from object, and inherits a bunch of properties (i.e. ToString()). Thus, (MyClass is object) should always evaluate as true. However, if I have a method with the following signature:
4
9596
by: Yansky | last post by:
Got a quick n00b question. What's the difference between del and remove?
3
2420
by: Riccardo Murri | last post by:
Hello, I have some code that stops when trying to find a graph in a list of similar graphs:: (Pydb) list 110 try: 111 canonical = self.base 112 except ValueError: 113 raise ValueError, \
11
12121
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my code is just returning me an array of 0's
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.