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. 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
"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
> You should get a 'missing function' error at link time.
No you won't.
Stephen Howe
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 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
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...
|
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:
|
by: Murat Ozgur |
last post by:
Hello,
Is there any difference between ArrayList and List<object? Which
one should I use ?
Thanks.
|
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:
| |
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:
|
by: Yansky |
last post by:
Got a quick n00b question. What's the difference between del and
remove?
|
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, \
|
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
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |