473,395 Members | 1,975 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,395 software developers and data experts.

Afew simple questions

Hi
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
2) Why do you sometimes have to use ^ after declaring a object, what exacly
does it do?
3) What is the diffrence between & and *? (I know that * is a pointer)
4) Managed and Unmanaged code, whats the diffrence?
I am trying to write a simple class:
when i compile i get the following error:
Error 1 error C3265: cannot declare a managed 'mId' in an unmanaged
'PatryManager::Party'
Error 2 error C3265: cannot declare a managed 'mName' in an unmanaged
'PatryManager::Party'

class Party
{
public:
Party();
Party(String^ id);
void NewId();
~Party();

private:
String^ mId;
String^ mName;
};

Party::Party()
{
}
Party::Party(String^ id)
{
mId = id;
}
Party::~Party()
{
// Destroy objects
}

void Party::NewId()
{
Random^ mRandGenerator;
int tempId = 0;

String^ mTemp = String::Empty;
char mLetterA[1];
char mLetterB[1];

tempId = mRandGenerator->Next(1000,9999);
mLetterA[0] = (char)mRandGenerator->Next(1,25);
mLetterB[0] = (char)mRandGenerator->Next(1,25);

mTemp = tempId.ToString() + mLetterA[0] + mLetterB[0];
mId = mTemp;
}
Jul 10 '06 #1
10 1722
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
.. is for selecting a member through an instance.
-is for selecitng a member through a pointer
:: is for selecting a scope / namespace
2) Why do you sometimes have to use ^ after declaring a object, what
exacly
does it do?
^ indicates a managed reference. this is something you use when working with
..NET classes.
3) What is the diffrence between & and *? (I know that * is a pointer)
& returns the address (reference) of an instance. * dereferences a pointer.
4) Managed and Unmanaged code, whats the diffrence?
managed code uses the common language runtime. you use managed code when
targetting the .NET framework.
unmanaged is when you compile to native code.
I am trying to write a simple class:
when i compile i get the following error:
Error 1 error C3265: cannot declare a managed 'mId' in an unmanaged
'PatryManager::Party'
Error 2 error C3265: cannot declare a managed 'mName' in an unmanaged
'PatryManager::Party'

class Party
{
public:
Party();
Party(String^ id);
void NewId();
~Party();

private:
String^ mId;
String^ mName;
};

Party::Party()
{
}
Party::Party(String^ id)
{
mId = id;
}
Party::~Party()
{
// Destroy objects
}

void Party::NewId()
{
Random^ mRandGenerator;
int tempId = 0;

String^ mTemp = String::Empty;
char mLetterA[1];
char mLetterB[1];

tempId = mRandGenerator->Next(1000,9999);
mLetterA[0] = (char)mRandGenerator->Next(1,25);
mLetterB[0] = (char)mRandGenerator->Next(1,25);

mTemp = tempId.ToString() + mLetterA[0] + mLetterB[0];
mId = mTemp;
}
you are mixing managed and unmanaged C++. this is not impossible, but there
are a number of rules that you have to follow.

I suggest you learn C++ first, and only start on managed code and mixed code
when you fully understand the basics.
otherwise you will run into problems with everything you do.
there are several good books on the topic of learning C++.
my favorite is still 'the C++ programming language, 3d edition' by bjarne
stroustrub.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jul 10 '06 #2
Bruno van Dooren wrote:
>Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
. is for selecting a member through an instance.
-is for selecitng a member through a pointer
>>is for selecting a scope / namespace
you meant :: here, not >>
>
>2) Why do you sometimes have to use ^ after declaring a object, what
exacly
does it do?

^ indicates a managed reference. this is something you use when
working with .NET classes.
Actually, ^ is a managed pointer (or handle), while % is a managed
reference.

-cd
Jul 11 '06 #3
>>>is for selecting a scope / namespace
>
you meant :: here, not >>
typo. my laptop keyboard has azerty layout. I have configured it as qwerty
(like every sane C++/C# programmer) but from time to time I mistype.
>>2) Why do you sometimes have to use ^ after declaring a object, what
exacly
does it do?

^ indicates a managed reference. this is something you use when
working with .NET classes.

Actually, ^ is a managed pointer (or handle), while % is a managed
reference.
Oops. It seems I confused terminology of 2 languages.
In C# the term 'reference' is used where C++ uses 'managed pointer'.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jul 11 '06 #4
Hi Carl and Bruno,
>>>is for selecting a scope / namespace

you meant :: here, not >>
Strange. In my reader, Bruno's response said:

":: is for selecting a scope / namespace"

Are you sure your newsreader doesn't interpret :: as a quote-prefix, Carl?

--
Best regards,
Kim Gräsman
Jul 11 '06 #5
>>>>is for selecting a scope / namespace
>>
you meant :: here, not >>

Strange. In my reader, Bruno's response said:

":: is for selecting a scope / namespace"

Are you sure your newsreader doesn't interpret :: as a quote-prefix, Carl?
I just went back to read it, and it says :: indeed.
Since the : is just above the on my imaginary qwerty keyboard, I figured I
mistyped.
I'm using OE btw.

I do know that '--' (without the quotes) indicates the beginning of a
signature in some news readers.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jul 11 '06 #6
Carl Daniel [VC++ MVP] <cp*****************************@mvps.org.nospamwr ote:
Bruno van Dooren wrote:
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
. is for selecting a member through an instance.
-is for selecitng a member through a pointer
:: is for selecting a scope / namespace

you meant :: here, not >>

You are using OE-QuoteFix, then? <g>
[...]
-cd
Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
Jul 11 '06 #7
Bruno van Dooren wrote:
>Actually, ^ is a managed pointer (or handle), while % is a managed
reference.

Oops. It seems I confused terminology of 2 languages.
In C# the term 'reference' is used where C++ uses 'managed pointer'.
Nice how they keep it consistent, eh?

-cd
Jul 11 '06 #8
Bruno van Dooren wrote:
>>>>>is for selecting a scope / namespace

you meant :: here, not >>

Strange. In my reader, Bruno's response said:

":: is for selecting a scope / namespace"

Are you sure your newsreader doesn't interpret :: as a quote-prefix,
Carl?
Wierd. May OEQuoteFix is "fixing" it for me. I don't think OE by itself
would do that, but I've been running with OEQuoteFix for so long, I forget
that it's there.

-cd
Jul 11 '06 #9
Hendrik Schober wrote:
Carl Daniel [VC++ MVP]
<cp*****************************@mvps.org.nospamwr ote:
>Bruno van Dooren wrote:
>>>Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
. is for selecting a member through an instance.
-is for selecitng a member through a pointer
is for selecting a scope / namespace

you meant :: here, not >>


You are using OE-QuoteFix, then? <g>
Yep.

-cd
Jul 11 '06 #10
Carl Daniel [VC++ MVP] <cp*****************************@mvps.org.nospamwr ote:
Hendrik Schober wrote:
Carl Daniel [VC++ MVP]
<cp*****************************@mvps.org.nospamwr ote:
Bruno van Dooren wrote:
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -and :: ?
. is for selecting a member through an instance.
-is for selecitng a member through a pointer
is for selecting a scope / namespace
>
you meant :: here, not >>

You are using OE-QuoteFix, then? <g>

Yep.
Press the Alt key and click on a mail/posting then
(see under Advanced Options).

:o>
-cd
Schobi

--
Sp******@gmx.de is never read
I'm Schobi at suespammers dot org

"The sarcasm is mightier than the sword."
Eric Jarvis
Jul 17 '06 #11

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

Similar topics

1
by: yiyun | last post by:
Hi, I am new to mysql and I want to ask a simple questions. I would like to initialize my InnoDB table space and I configure like below: ...
18
by: Geoff Cox | last post by:
Hello, I am trying to print out the array values for a second time but get error on page message? Thanks Geoff <html>
1
by: Proteus | last post by:
Any help appreciated on a small perl project I need to write for educator/teaching purposes. I have not programmed perl for some time, need to get up to speed, maybe some kind souls hrere will help...
1
by: number1.email | last post by:
Hello, I have a simple Web Page Questionairre in which questions are read from a database, and the user can indicate the correct answer via either a radio input control or a dropdown list. The...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
1
by: E.T. Grey | last post by:
I have been busting my nut over this for pretty much most of the day and it is driving me nuts. I posted this to an mySQL ng yesterday and I have not had any response (I'm pulling my hair out...
7
by: javedna | last post by:
Hi guys Ive got a simple problem, im designing an online questionnaire and on submission the coding that I have used to validate whether a user has filled in all the questions is supposed to...
1
by: chelisek | last post by:
I have two simple questions: I am trying to create a document using an excel spreadsheet format. I am trying to create a column that will contain numbers, just plain numbers as in account numbers...
1
by: Itanium | last post by:
Hi all! I'm new to .NET Platform and got some simple questions about efficiency... To put you in situation, to say that I'm involved in the writing of a complex regex based lexer for use over...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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,...

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.