Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7832121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:03:13+00:00 2026-06-02T12:03:13+00:00

unsigned char *check = NULL; check = (dynamic_cast<unsigned char *>( ns3::NetDevice::GetChannel() )); This is

  • 0
unsigned char *check = NULL;
check = (dynamic_cast<unsigned char *>( ns3::NetDevice::GetChannel() ));

This is what I am trying. But the error is:

error: cannot dynamic_cast ‘ns3::NetDevice::GetChannel() const()’ (of type ‘class       ns3::Ptr<ns3::Channel>’) to type ‘unsigned char*’ (target is not pointer or reference to class)

I also tried:

reinterpret_cast

But it doesn’t work at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:03:18+00:00Added an answer on June 2, 2026 at 12:03 pm

    The return type of ns3::NetDevice::GetChannel() is some kind of custom smart pointer; without seeing the definition of that, we can only guess at how you can convert that into a raw pointer.

    Perhaps it implements a conversion operator, operator T*(), although that’s generally regarded as a bad idea since it makes it unintended conversions too easy to do by accident. In that case, you could do:

    void * check = ns3::NetDevice::GetChannel();
    

    Otherwise, perhaps it has a member function to convert to a raw pointer. The standard smart pointers conventionally call this get():

    void * check = ns3::NetDevice::GetChannel().get();
    

    If it doesn’t offer that, and you really do want to get a raw pointer, then you could dereference it and take a pointer to the dereferenced object (assuming it supports dererencing; otherwise, it’s a bit odd to call it a pointer at all):

    void * check = &*ns3::NetDevice::GetChannel();
    

    Once you have a void *, you can use static_cast to change it into unsigned char *, if that’s what you want. Be careful what you do with it, since messing around with the bytes of an object can easily lead to undefined behaviour.

    UPDATE: if ns3::Ptr is the template documented here, then you can get the raw pointer using:

    void * check = PeekPointer(ns3::NetDevice::GetChannel());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an unsigned char and I need to check bits 1 and 2
I have an unsigned char array whose size is 6. The content of the
I have unsigned char* , want to convert it to std::string . Can you
char *pStrBuffer; unsigned char data; unsigned int Address; /* pStrBuffer reading from a file
I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
i got a question about unsigned char array. How can i store an integer
I have a double converted to a unsigned char array. For example for value
How can I get decimal from string hexdecimal: I have unsigned char* hexBuffer =
How can I convert the following struct to unsigned char* ? typedef struct {
I have a small sample function: #define VALUE 0 int test(unsigned char x) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.