Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-28-2005, 01:18 PM   #1
Senior Member
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
difference between () and = when declaring variables

simple question.. im well educated in java but not in c++. im reading about pointers right now and in examples i see, for example:
int myval(5);
int anotherVar = 3;
they do the same thing right? using (x) is just another way of doing =x, i assume?

thanks for the input.
Old 06-28-2005, 01:37 PM   #2
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
They are equivalents in this case... but you have to be careful.

The blah var() syntax actually calls the constructor for the class blah. In the case of the primitives that will always work, in the case of non-primitives you can only do that if they have a constructor defined with the parameters you are passing in.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault after declaring a large array. oulevon Programming 6 11-08-2005 02:41 AM
C++: Trouble declaring dynamic array Hady Programming 7 11-01-2005 01:06 AM
questions about declaring functions? alaios Programming 4 07-21-2005 02:25 AM
C: declaring void parameters jrtayloriv Programming 4 02-11-2005 02:20 PM
Winex declaring itself already installed when I try to install it Floydian Linux - Newbie 5 12-29-2004 01:58 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration