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 7023435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:42:39+00:00 2026-05-27T23:42:39+00:00

I’m not sure if this is a proper programming question, but it’s something that

  • 0

I’m not sure if this is a proper programming question, but it’s something that has always bothered me, and I wonder if I’m the only one.

When initially learning C++, I understood the concept of references, but pointers had me confused. Why, you ask? Because of how you declare a pointer.

Consider the following:

void foo(int* bar)
{
}


int main()
{
    int x = 5;
    int* y = NULL;

    y = &x;
    *y = 15;     
    foo(y);

}

The function foo(int*) takes an int pointer as parameter. Since I’ve declared y as int pointer, I can pass y to foo, but when first learning C++ I associated the * symbol with dereferencing, as such I figured a dereferenced int needed to be passed. I would try to pass *y into foo, which obviously doesn’t work.

Wouldn’t it have been easier to have a separate operator for declaring a pointer? (or for dereferencing). For example:

void test(int@ x)
{
}
  • 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-27T23:42:40+00:00Added an answer on May 27, 2026 at 11:42 pm

    In The Development of the C Language, Dennis Ritchie explains his reasoning thusly:

    The second innovation that most clearly distinguishes C from its
    predecessors is this fuller type structure and especially its
    expression in the syntax of declarations… given an object of any
    type, it should be possible to describe a new object that gathers
    several into an array, yields it from a function, or is a pointer to
    it…. [This] led to a
    declaration syntax for names mirroring that of the expression syntax
    in which the names typically appear.
    Thus,

    int i, *pi, **ppi; declare an integer, a pointer to an integer, a
    pointer to a pointer to an integer. The syntax of these declarations
    reflects the observation that i, *pi, and **ppi all yield an int type
    when used in an expression.

    Similarly, int f(), *f(), (*f)(); declare
    a function returning an integer, a function returning a pointer to an
    integer, a pointer to a function returning an integer. int *api[10],
    (*pai)[10];
    declare an array of pointers to integers, and a pointer to
    an array of integers.

    In all these cases the declaration of a
    variable resembles its usage in an expression whose type is the one
    named at the head of the declaration
    .

    An accident of syntax contributed to the perceived complexity of the
    language. The indirection operator, spelled * in C, is syntactically a
    unary prefix operator, just as in BCPL and B. This works well in
    simple expressions, but in more complex cases, parentheses are
    required to direct the parsing. For example, to distinguish
    indirection through the value returned by a function from calling a
    function designated by a pointer, one writes *fp() and (*pf)()
    respectively. The style used in expressions carries through to
    declarations, so the names might be declared

    int *fp(); int (*pf)();

    In more ornate but still realistic cases,
    things become worse: int *(*pfp)(); is a pointer to a function
    returning a pointer to an integer.

    There are two effects occurring.
    Most important, C has a relatively rich set of ways of describing
    types (compared, say, with Pascal). Declarations in languages as
    expressive as C—Algol 68, for example—describe objects equally hard to
    understand, simply because the objects themselves are complex. A
    second effect owes to details of the syntax. Declarations in C must be
    read in an `inside-out’ style that many find difficult to grasp.
    Sethi [Sethi 81] observed that many of the nested
    declarations and expressions would become simpler if the indirection
    operator had been taken as a postfix operator instead of prefix, but
    by then it was too late to change.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.