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

The Archive Base Latest Questions

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

class SimpleCat { public: SimpleCat(); SimpleCat(SimpleCat&); ~SimpleCat(); }; SimpleCat::SimpleCat() { cout << Simple Cat

  • 0
    class SimpleCat
{
public:
    SimpleCat();
    SimpleCat(SimpleCat&);
    ~SimpleCat();
};

SimpleCat::SimpleCat()
{
    cout << "Simple Cat Constructor.. \n";
}

SimpleCat::SimpleCat(SimpleCat&)
{
    cout << "Simple Cat Copy Constructor ..\n";
}

SimpleCat::~SimpleCat()
{
    cout << "Simple Cat Destructor! ... \n";
}

SimpleCat *FunctionTwo(SimpleCat *theCat);

void main()
{
    cout << "Making a cat ...\n";
    SimpleCat Frisky;
    cout << "Calling FunctionTwo ..\n";
    FunctionTwo(&Frisky);
    system("pause");
}

SimpleCat *FunctionTwo (SimpleCat *theCat)
{
    cout << "FunctionTwo, Returning... \n";
    return theCat;
}

Ok, so what i don’t understand is, why do you need the * for FunctionTwo? If you really want to do me a favor, can someone please break down the code for me (the pointer part, because i seriously don’t understand when and why to use the * and &.

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

    FunctionTwo returns a pointer to a SimpleCat object. As you can see there, it also accepts a pointer to a SimpleCat object as a parameter. It’s just accepting the pointer and then returning it in this case.

    To call that function, you need to pass a pointer to it. If you want to pass Frisky to the function, you need to pass the address of the object Frisky. This is what is being done when &Frisky is written. A pointer is created with the address of the Frisky object.

    However, when a similar statement is written in the parameter list of a function, i.e. SomeFunction(SimpleCat& Frisky) what it is telling you is that objects are passed to the function by reference. This basically allows you to use one of the advantages of pointers without worrying about pointer syntax. You would call the function normally by saying SomeFunction(Frisky), and within the function you would use Frisky with the same syntax as you would within the main function, but you should remember that the object is not copied. Both within main and within SomeFunction, you are performing operations on the exact same object. It is not copied. Only the information required to access Frisky is given to the function.

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

Sidebar

Related Questions

Let's look at the simple Java code in the following snippet: public class Main
class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple
class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class
class C { T a; public: C(T a): a(a) {;} }; Is it legal?
Suppose I have this: public class Unit<MobileSuit, Pilot> { ... List<MobileSuit> mobileSuits; List<Pilot> pilots;
Let's say I have a class public class MyObject { public int SimpleInt {
custom view: public class MyView extends AbstractView { .... awesome stuff ... } controller:
I wanted to do something along the lines of: public class MyClass<T implements Comparable>
Let's see the following simplest code snippet in Java. final public class Parsing {
I have a custom UIComponent that is basically just this: public class WhiteboardUIComponent extends

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.