Answers for "^~~ cpp"

C++
1

C++ ::

/* :: is the scope resolution operator
 *
 * It allows to access objects outside of their scope, e.g to implement
 * a function of a class from outside the class
 */

class foo {      // define class named foo
  public:
    foo();       // constructor
    void bar();  // function
};

foo::foo()
{
  // Implement the constructor from outside the class
}

void foo::bar()
{
  // Implement bar from outside the class
}

void bar()
{
  // Implement different bar which is not within the same scope
}
Posted by: Guest on October-27-2021
-1

? c++

The Conditional (or Ternary) Operator (?:)

(expression 1) ? expression 2 : expression 3

If expression 1 evaluates to true, then expression 2 is evaluated.

If expression 1 evaluates to false, then expression 3 is evaluated instead.
  
// ternary operator checks if
// marks is greater than 40
int marks = 50;
string result = (marks >= 40) ? "passed" : "failed";
// result = "passed"
Posted by: Guest on December-01-2021

Browse Popular Code Answers by Language