difference between "list" and "list()" in the below code ?

Hi
What is the difference between "list" and "list()" in the below code ?

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

#include "mycpp_linklist_class_01.h"
using namespace std;

int main() {

	NumberList  list;
	NumberList  list();
	
}
The second one declares a function called list that returns a NumberList.
If it looks like a function declaration the compiler will treat it as a function declaration.

Declares a function named list that takes no arguments and returns a NumberList object.
 
NumberList  list();

Creates a NumberList object named list using the default constructor.
 
NumberList  list;
Last edited on
thanks
Topic archived. No new replies allowed.