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

  • Home
  • SEARCH
  • 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 6810867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:15:28+00:00 2026-05-26T20:15:28+00:00

In C++, these two have no difference. char *pC; char* pC2; I thought that

  • 0

In C++, these two have no difference.

char *pC;
char* pC2;

I thought that the type char and char* have got to be different types and all the C++ programmers had to use this form char* p instead of char *p, because when you do char *p it doesn’t seem to specify that the programmer is using a pointer to char.

However, when you take a look at this code below, which is the same as nullptr from C++0x, it seems that T doesn’t recognize any pointer type.

const class{
public:
    // T is char, not char* in this case.
    // T* is char*, but I thought it would be char**
    template <class T>
    operator T*() const{   
        cout << "Operator T*() Called" << endl;
        return 0;
    }

    template <class C, class T> 
    operator T C::*() const{
        cout << "Operator C T::*() Called" << endl;
        return 0;
    }

private:
    void operator&() const;
}AAA = {};

int main(){
 // operator T*() const is called, 
 // but it's awkward,
 // because it looks like T will be char* type, so T* will be char**
    char* pC = AAA;
}

Thanks in advance!

  • 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-05-26T20:15:29+00:00Added an answer on May 26, 2026 at 8:15 pm

    You’re correct that char and char* are different types. Whether programmers say char* p or char *p is irrelevant. Those are three separate tokens, and there can be as many or as few spaces between them as you want; it has no effect on the type of p.

    When you initialize pC with AAA, the compiler needs to choose a conversion operator from AAA. Since it’s initializing a char* variable, it wants operator char*. To make that work, the compiler needs to choose T = char. Since T is char, there’s no way T* could be char**.

    If you want T to be a pointer type, then use AAA in a context where a pointer-to-pointer type is expected, such as char**. Then T will be char*.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two select statements and make 'union all' for these two statements. Then,
Do these two keywords have exactly the same effect, or is there something I
I have two Collection objects, I want to associate each object of these two
We have two tables Family and Member, the relation between these two is Family
I have two WCF clients consuming a 3rd party web service. These two clients
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
Say you have these two methods: Number 1: void AddPerson(Person person) { // Validate
If I have these two tables: <table> <tr> <td>Small Length Content</td> </tr> </table> <table>
I have these two pieces of code, wich one is more readable? foreach decimal
In AD we have these two OUs: OU=Accounts - Standard User OU=Accounts - Restricted

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.