473,399 Members | 3,888 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,399 software developers and data experts.

considering taking the plunge

hi all

i'm thinking of "diving into c++", but first i have a couple of
general questions which hopefully somebody here will be kind enough to
answer. my programming background is that i'm fairly familiar with
python, and i once took a single-semester course in c++, although that
was some time ago. here are the questions:

*) are class-instances first class, in the sense of being permissible
arguments for a function and also permissible return-values for a
function?

*) same question as above, except substitute "pointers" for "class-
instances"

hopefully these questions aren't too retarded. unfortunately my c++
instructor was something of a chucklehead; i never managed to see the
big picture, so most of the knowledge subsequently leaked out of my
ears. anyway, thanks if you can help.

peace
stm
Sep 15 '08 #1
4 1272
Sean McIlroy wrote:
i'm thinking of "diving into c++", but first i have a couple of
general questions which hopefully somebody here will be kind enough to
answer. my programming background is that i'm fairly familiar with
python, and i once took a single-semester course in c++, although that
was some time ago. here are the questions:

*) are class-instances first class, in the sense of being permissible
arguments for a function and also permissible return-values for a
function?
Yes. You are allowed to return objects from functions, if that's the
correct understanding of your question.
*) same question as above, except substitute "pointers" for "class-
instances"
Yes, pointers are objects. Even further, you can return references from
functions even though references are not objects.
hopefully these questions aren't too retarded. unfortunately my c++
instructor was something of a chucklehead; i never managed to see the
big picture, so most of the knowledge subsequently leaked out of my
ears. anyway, thanks if you can help.
Get a good book and you can probably undo most of the damage done by
your instructor.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 15 '08 #2
On Sep 15, 2:21*pm, Sean McIlroy <sean_mcil...@yahoo.comwrote:
*) are class-instances first class, in the sense of being permissible
arguments for a function and also permissible return-values for a
function?
Yes
*) same question as above, except substitute "pointers" for "class-
instances"
Yes. And the same goes for references as well.

hopefully these questions aren't too retarded. unfortunately my c++
instructor was something of a chucklehead; i never managed to see the
big picture, so most of the knowledge subsequently leaked out of my
ears. anyway, thanks if you can help.
Get a copy of "Accelerated C++" by Koenig and Moo. It's a great book
for beginners who have some programming experience.

Sep 15 '08 #3
On Sep 15, 2:51*pm, red floyd <redfl...@gmail.comwrote:
On Sep 15, 2:21*pm, Sean McIlroy <sean_mcil...@yahoo.comwrote:
*) are class-instances first class, in the sense of being permissible
arguments for a function and also permissible return-values for a
function?

Yes
*) same question as above, except substitute "pointers" for "class-
instances"

Yes. *And the same goes for references as well.
hopefully these questions aren't too retarded. unfortunately my c++
instructor was something of a chucklehead; i never managed to see the
big picture, so most of the knowledge subsequently leaked out of my
ears. anyway, thanks if you can help.

Get a copy of "Accelerated C++" by Koenig and Moo. *It's a great book
for beginners who have some programming experience.
i'll look for it. thanks
Sep 16 '08 #4
On 15 Sep, 22:21, Sean McIlroy <sean_mcil...@yahoo.comwrote:
*) are class-instances first class, in the sense of being permissible
arguments for a function and also permissible return-values for a
function?
Instances of classes are, yes.
*) same question as above, except substitute "pointers" for "class-
instances"
I'm not overly familiar with the terminology but I know how these
things work so can say the pointers themselves can be copied, assigned
to, etc just like an int or char can, so are first class. The objects
the pointers point to do not get copied when you copy the pointer.

I was reading the Modern C++ Design book last night by Andrei
Alexandrescu (second print). Section 7.2. There's a comparison between
simple pointers and smart pointers and he says:

"An object with value semantics is an object that you can copy and
assign to. Type int is the perfect example of a first-class object
....
Consequently pointers to allocated objects do not have value semantics
- you cannot copy and assign to them at will."

So could you define what you mean by first class, as pointers may or
may not be first class depending on your definition.

Regards,

Pete
Sep 16 '08 #5

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

Similar topics

2
by: Brent | last post by:
Hello all.. I have a recordset that has 12 records in it, and about 25 columns. Unfortunately, I have to write the records out as columns in an ASP page, and the columns as rows. So, what I have done...
4
by: Alan Mailer | last post by:
I'm thinking about FINALLY making the transition from VB6 to VB.net. A couple of questions first: 1) Is VB.net 2003 the latest edition? If so, are there any rumors that a newer version will be...
11
by: Tim | last post by:
I have been using for the last few years, VB 6 Professional. I'm considering getting .Net now. Will I still be able to keep VB 6 installed, or will VB .Net totally replace it? Also, is it a LOT...
7
by: Wowbagger | last post by:
I am considering upgrading from vb 6 to .net 2003 and have a couple of questions for which I could not find answers on the MS site. What are the differences between the standard, professional and...
3
by: Jim Langston | last post by:
I really am not sure if this question belongs in this newsgroup, but not sure where else to ask it. There is someone working on a game that I tested, and it was taking >30 seconds to load. He...
4
by: Bruce One | last post by:
Well folks, considering the high prices for the current VSTS MSDN Premium subscription, I propose we take a pause and look of what each one of the 3 possible package DOES NOT have: Team Edition...
3
by: jmark | last post by:
I have PHP 5.2.1 running on Windows XP home. The problem I have is that programs run in the command line are taking more than 10 minutes to exit. Does anyone know a solution to this?
2
by: Kumarswamy | last post by:
Hi, I have a problem, i have used one condition in where clause ..... but it is taking some time to return values....... so my procedure is taking lot of time....... for the same table if i query...
4
by: eliane | last post by:
For some reason, DB2 is taking a long time to start archiving the logs. Pls, do you know what could be causing it? I see the following msgs on db2diag.log 2008-09-04-00.36.24.414103+000...
1
by: anujkgarg | last post by:
I am trying to fetch public key from DSA certificate using .NET cryptography API. It is taking 15 to 45 seconds..... String crtFileName = "C:\mycert.crt"; X509Certificate2 x509...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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,...
0
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...

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.