Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

difference

78 views
Skip to first unread message

K' Dash

unread,
Nov 1, 2014, 6:58:08 PM11/1/14
to
what is the difference between

Mac48Address* Mac

and

Ptr<Mac48Address> Mac

where Mac48Address is a class

jacob navia

unread,
Nov 1, 2014, 7:11:15 PM11/1/14
to
"Mac48Address* Mac"

You know immediately what "Mac" is: a pointer to some class, in this
case a Mac48Address.

"Ptr<Mac48Address> Mac"

Who knows?

You have to go fishing for the definition of "Ptr"

K' Dash

unread,
Nov 1, 2014, 7:51:47 PM11/1/14
to
Ptr<Mac48Address> Mac

people call it smart pointer. but I dont know the exact difference.
Ptr is a class also, because when I click on Ptr<Mac48Address> Mac, then IDE show me this "class ptr". they mixed things with templates. :(
Message has been deleted
Message has been deleted

Ben Bacarisse

unread,
Nov 1, 2014, 8:38:03 PM11/1/14
to
r...@zedat.fu-berlin.de (Stefan Ram) writes:

> jacob navia <ja...@spamsink.net> writes:
>>You know immediately what "Mac" is: a pointer to some class
>
> This might be so in C.

Since C does not have classes, that's not possible.

> But in C++ there also are so-called »alias-declarations«
> by which »Mac48Address« does not have to be class!

True, but Jacob was just using information given by the op:

| where Mac48Address is a class

<snip>
--
Ben.
Message has been deleted

Jorgen Grahn

unread,
Nov 1, 2014, 9:50:30 PM11/1/14
to
It's like with everything else: to use it you have to read the
documentation. This Ptr<T> thing seems to be a smart pointer of some
kind, but it's not one of those defined by the C++ language, so
exactly what it does is anyone's guess. The name doesn't exactly give
any clues ...

Who are "they"?

BTW, it also seems a bit unusual to have a smart pointer to a
"Mac48Address", which surely is an Ethernet address. These are small
enough to be treated the same way as e.g. an int: copied when someone
else needs them and so on.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

jacob navia

unread,
Nov 2, 2014, 2:05:37 AM11/2/14
to
Le 02/11/2014 01:21, Stefan Ram a écrit :
> jacob navia<ja...@spamsink.net> writes:
>> >You know immediately what "Mac" is: a pointer to some class
> This might be so in C.
>
> But in C++ there also are so-called »alias-declarations«
> by which »Mac48Address« does not have to be class!

Excuse, I forgot that.

Thanks for confirming, C++ is unreadable. Actually you can NEVER know
what you are reading since most words can be redefined at will.

Luckily we don't do that in natural language. Imagine what would happen
if we could do in english:

using yes = no;
using no = yes;

and Romeo and Juliette talking in a warm summer night...

:-)


Paavo Helde

unread,
Nov 2, 2014, 3:27:15 AM11/2/14
to
jacob navia <ja...@spamsink.net> wrote in news:m34l3e$rsv$1
@speranza.aioe.org:

> Le 02/11/2014 01:21, Stefan Ram a écrit :
>> jacob navia<ja...@spamsink.net> writes:
>>> >You know immediately what "Mac" is: a pointer to some class
>> This might be so in C.
>>
>> But in C++ there also are so-called »alias-declarations«
>> by which »Mac48Address« does not have to be class!
>
> Excuse, I forgot that.
>
> Thanks for confirming, C++ is unreadable. Actually you can NEVER know
> what you are reading since most words can be redefined at will.

Yes, one can shoot yourself in the foot in many ways in C++ and in C, or
one can choose names which are useful. "Ptr" actually contains some hint
that it is a pointer. "*" on the other hand does not convey any such
information, you have to know what it means.

Besides, it is also possible in C to have "typedef Mac48Address* Ptr".
Microsoft uses things like that a lot (LPCTSTR et. al.). Not saying this is
good for anything.

Cheers
Paavo

Jorgen Grahn

unread,
Nov 2, 2014, 3:40:40 AM11/2/14
to
The situation in C is worse, because

- Typedefs are used a lot more in many subcultures (e.g. Microsoft).
One API I'm using has

typedef char* String;
typedef const char* ConstString;

and I fail to see the point of such exercises.

- It is more common in C that you /do/ need to know what something
really is, since the "irregular" types are so much more used:
pointers, arrays, the struct hack ...

K' Dash

unread,
Nov 2, 2014, 1:32:25 PM11/2/14
to
Still I am unable to understand that what you guys are saying. You guys discussing with each other instead of teaching me. :)

see this link,

http://www.nsnam.org/docs/release/3.21/doxygen/ptr_8h_source.html

when I click (by using eclipse IDE) on Ptr<Mac48Address> Mac;
it showed me the "class Ptr " at line number 60. you can see this class from above link.

generic command is Ptr<classname> variable;
so don't confuse yourself with Mac48Address. Now please tell me what is the difference between

Mac48Address* Mac;

and

Ptr<Mac48Address> Mac;

where Mac48Address is a class name
















Melzzzzz

unread,
Nov 2, 2014, 1:34:56 PM11/2/14
to
On Sun, 2 Nov 2014 10:32:12 -0800 (PST)
"K' Dash" <adnanr...@gmail.com> wrote:

>
> Mac48Address* Mac;
>
> and
>
> Ptr<Mac48Address> Mac;
>
> where Mac48Address is a class name

First you tell me what is a difference
between int* v and Ptr<int> v?

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



--
Manjaro all the way!
http://manjaro.org/

K' Dash

unread,
Nov 2, 2014, 1:36:54 PM11/2/14
to
I don't know. :(

K' Dash

unread,
Nov 2, 2014, 1:38:41 PM11/2/14
to
int* v;
v is a pointer and we can use this "v" to assign the address of int variables only. but i dont know the other thing.

Jorgen Grahn

unread,
Nov 2, 2014, 1:51:08 PM11/2/14
to
On Sun, 2014-11-02, K' Dash wrote:

> Still I am unable to understand that what you guys are saying. You
> guys discussing with each other instead of teaching me. :)

That's what we do best these days.

> see this link,
>
> http://www.nsnam.org/docs/release/3.21/doxygen/ptr_8h_source.html
>
> when I click (by using eclipse IDE) on Ptr<Mac48Address> Mac;
> it showed me the "class Ptr " at line number 60. you can see this class from above link.
>
> generic command is Ptr<classname> variable;
> so don't confuse yourself with Mac48Address. Now please tell me what is the difference between
>
> Mac48Address* Mac;
>
> and
>
> Ptr<Mac48Address> Mac;
>
> where Mac48Address is a class name

Ignore that line 60. If you look deeper in that Doxygen-generated
documentation, you find:

template<typename T>
class ns3::Ptr< T >

smart pointer class similar to boost::intrusive_ptr

This smart-pointer class assumes that the underlying type provides
a pair of Ref and Unref methods which are expected to increment
and decrement the internal refcount of the object instance.

This implementation allows you to manipulate the smart pointer as
if it was a normal pointer: you can compare it with zero, compare
it against other pointers, assign zero to it, etc.
...

I'm not very familiar with smart pointers so I might be missing
something, but this documentation seems rather poor. Am I supposed to
read the documentation for boost::intrusive_ptr to understand what
ns3::Ptr does?

Öö Tiib

unread,
Nov 2, 2014, 2:24:34 PM11/2/14
to
On Sunday, 2 November 2014 20:32:25 UTC+2, K' Dash wrote:
> Still I am unable to understand that what you guys are saying. You
> guys discussing with each other instead of teaching me. :)

Perhaps you are under necessary level of grasp of the matter
so whatever answer you get you are unable to understand it?

> see this link,
> http://www.nsnam.org/docs/release/3.21/doxygen/ptr_8h_source.html
>
> when I click (by using eclipse IDE) on Ptr<Mac48Address> Mac;
> it showed me the "class Ptr " at line number 60. you can see this class
> from above link.
>
> generic command is Ptr<classname> variable;
> so don't confuse yourself with Mac48Address. Now please tell me what is
> the difference between
>
> Mac48Address* Mac;

It declares mutable variable 'Mac' of type 'Mac48Address*' that is raw
pointer to 'Mac48Address'.

> and
>
> Ptr<Mac48Address> Mac;

It declares mutable variable 'Mac' of type 'Ptr<Mac48Address>' that
is class template 'Ptr' instantiated with type 'Mac48Address'.

> where Mac48Address is a class name

I am not sure what you expect us to tell is "different" and what
you assume is "common" there.
Message has been deleted

JiiPee

unread,
Nov 2, 2014, 6:53:18 PM11/2/14
to
imo this is just bad. char* is not a string...its just not....


Chris Vine

unread,
Nov 2, 2014, 7:16:51 PM11/2/14
to
You admit to not knowing C++. It appears that you don't know C
either. In this usage, 'using' is just another spelling (and ordering)
of typedef. Both alias types.

Chris

Christian Gollwitzer

unread,
Dec 20, 2014, 3:38:13 AM12/20/14
to
Am 02.11.14 08:05, schrieb jacob navia:
> Luckily we don't do that in natural language. Imagine what would happen
> if we could do in english:
>
> using yes = no;
> using no = yes;
>
> and Romeo and Juliette talking in a warm summer night...

Actually, this is often erroneously declared in class Woman.

;)

Christian

0 new messages