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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:42:18+00:00 2026-05-23T18:42:18+00:00

in c++ class bar { int i; char b; float d; }; void foo

  • 0

in c++

class bar
{
    int i;
    char b;
    float d;
};

void foo ( bar arg );
void foo ( bar &arg );
void foo ( bar *arg );

this is a sample class/struct and functions
i have some Qs

  • what’s the difference between 1st and 2nd way of passing the argument in ‘asm’, size, speed ?
  • how the arguments are passed to the functions foo in each case ( in case of pointer i know the pointer is pushed on the stack )
  • when passing arguments, in terms of efficiency at ( speed, size, preferability ) which is better ?
  • what’s the intel ‘asm’ syntax that corresponds each of the ways of passing arguments ?

i know what most say about “it doesn’t matter on modern compilers and CPUs” but what if we’re talking about Old CPUs or compilers?

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-23T18:42:18+00:00Added an answer on May 23, 2026 at 6:42 pm

    The pointer and the reference methods should be quite comparable (both in speed, memory usage and generated code).

    Passing a class directly forces the compiler to duplicate memory and put a copy of the bar object on the stack. What’s worse, in C++ there are all sort of nasty bits (the default copy constructor and whatnot) associated with this.

    In C I always use (possibly const) pointers. In C++ you should likely use references.

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

Sidebar

Related Questions

I have the following class definitions in c++: struct Foo { int x; char
Say I have some code like this: class Foo { public: Foo(int v) :
Suppose we have: interface Foo { bool Func(int x); } class Bar: Foo {
Specifically, is the following legal C++? class A{}; void foo(A*); void bar(const A&); int
If I do this: // In header class Foo { void foo(bar*); }; //
Say I have a macro, FOO(name), and some template class Bar<> that takes one
I have a linked list structure: struct SomeLinkedList { const char* bar; int lots_of_interesting_stuff_in_here;
I have the classes Foo and Bar : public class Foo { public int
class foo { public void bar(int i) { ... }; public void bar(long i)
Suppose I have code like this: template<class T, T initial_t> class Bar { //

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.