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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:39:42+00:00 2026-06-01T02:39:42+00:00

I was given a c++ main and have to code it so it works.

  • 0

I was given a c++ main and have to code it so it works.

I am having some trouble understanding the code as I am a bit new to cpp.

Here is the code

int main(int argc, char *argv[]) {
  Class::setAtribute("string"); 
  Class(Class::CONSTANT) << "starting up..."; 
}

Some questions:

  1. How can the first line work with no variables? Is it static?

  2. The second line is really strange for me, what I can make out is a Constructor that takes in a class constante and then prints it out somehow?

    If someone could explain me this bit of code it would be great!

    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-06-01T02:39:43+00:00Added an answer on June 1, 2026 at 2:39 am

    How can the first line work with no variables? Is it static?

    Class::setAtribute() must be a static function in class Class. A static function doesn’t need an instance of a class (object).

    The second line is really strange for me, what I can make out is a Constructor that takes in a class constante and then prints it out somehow?

    Right, it constructs an instance of Class passing Class::CONSTANT as the argument to Class constructor. For Class(Class::CONSTANT) << "starting up..."; to compile there must be an overloaded operator<< in the form of:

    As a member function of Class (David Rodríguez – dribeas):

    <some_return_value_type> Class::operator<<(char const*);
    

    or as a free-standing function:

    <some_return_value_type> operator<<(Class const&, char const*);
    

    or:

    <some_return_value_type> operator<<(Class const&, std::string const&);
    

    or, in C++11:

    <some_return_value_type> operator<<(Class&&, char const*);
    

    The second argument, in fact, can be anything that can be constructed from a string literal char const[]. Or, alternatively, Class can have a conversion operator to, say, std::ostream&, so that std::ostream& std::operator<<(std::ostream&, char const*) is picked instead. Looking at Class definition and free-standing functions in its namespace must yield a definite answer.

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

Sidebar

Related Questions

I'm new to Java and I'm having a bit of trouble understanding the concept
Given the following code: Hashtable main = new Hashtable(); Hashtable inner = new Hashtable();
I have a html main.html as given ----- main.html---------------- <title>FlexTrail</title> <script src=main.js></script> <frameset rows='200,200'>
consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
I have an online repository with some .h and .cpp files that make up
I'm having a kind of trouble since I'm new the concept Image Analysis and
I currently have the code below it works fine up until I actually try
I'm having a spot of trouble with generics in C#. I have to store
having some doubts with LINQ queries over objects... I have this filter descriptions which
My main question is given a feature centroid, how can I draw it in

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.