1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
geniusboy [140]
3 years ago
9

Define Class in C++. Briefly discuss.

Computers and Technology
1 answer:
lesya [120]3 years ago
3 0

Answer:

Class are the collection of variable and member function.

Class are the blueprint of an object.

Explanation:

Following are the points regarding class in c++

1.In C++ class is an user defined datatype..

2.Classes are the collection of variable and function in c++.

3.To access the property of class we can create object of that class

4.We can use following syntax to declared any class in c++

class classname

{

accessmodifier:

//statement and function

};

main()

{

classname objectname;

}

implementation of class in c++

#include<iostream>

class test // class declaration

{

public: // access modifier

void fun3() // Method definition

{

cout<<" hello :";

}

};

void main() // main function

{

test ob;// creating object

ob.fun3(); // calling function

}

In this program we declared a class "test " in class test. We giving public access modifier .The public access modifier define that variable and function are accessible outside the class and in main method we create the object ob which call the function fun3().

Output:hello :

You might be interested in
Write the definition of a function named printpoweroftwostars that receives a non-negative integer n and prints a line consistin
Aleksandr-060686 [28]
To accomplish this without using a loop,
we can use math on a string.

Example:
print("apple" * 8)

Output:
appleappleappleappleappleappleappleapple

In this example,
the multiplication by 8 actually creates 8 copies of the string.

So that's the type of logic we want to apply to our problem.

<span>def powersOfTwo(number):
if number >= 0:
return print("*" * 2**number)
else:
<span>return

Hmm I can't make indentations in this box,
so it's doesn't format correctly.
Hopefully you get the idea though.

We're taking the string containing an asterisk and copying it 2^(number) times.

Beyond that you will need to call the function below.
Test it with some different values.

powersOfTwo(4) should print 2^4 asterisks: ****************</span></span>
4 0
3 years ago
Will give brainly pls help
Bad White [126]

Answer:

False

Explanation:

You can change it to landscape

7 0
3 years ago
Read 2 more answers
What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout &lt
Lunna [17]

Answer:

The answer is "Hello!".

Explanation:

  • In the given C++ language program, a class "TestClass " is defined, which contains a parameterized constructor and default constructor.
  • In the parameterized constructor an integer variable "x" is passed in the constructor parameter and inside a constructor parameter value is print. Inside the default constructor, a print function (cout) is used that print message "Hello!".
  • In the main method, a class "TestClass" object is created that is "test" when a class object is created it automatically called a default constructor that's why the output to this code is "Hello!".

6 0
3 years ago
The term that best exemplifles the freedom to spend your money the want to is
e-lub [12.9K]
Want to spend it on things u need THEN you can buy what you wNt
6 0
3 years ago
To all the moderators i just wanna say im sorry for spamming .
const2013 [10]

Answer:uwu

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • What effects will the different types of lighting produce on mountains?
    15·1 answer
  • Which type of movement lets the player control an object's movement?
    5·1 answer
  • 100 POINTS + BRAINLYEST TO FIRST PERSON THAT IS CORRECT!!! Tomika wants to create a cell style for her workbook and share it wit
    13·2 answers
  • ​Microsoft claims that the microsoft project software can _____.
    11·1 answer
  • What is impact of Internet<br> in our lives
    7·1 answer
  • List 5 ways that computers could be used in a school or university
    15·1 answer
  • ANSWER QUICKLY PLEASE
    7·1 answer
  • A(n)<br> is a fast compute with lots of storage. pls help
    7·2 answers
  • Define the term algorithm and describe how programmers use algorithms when designing a program.
    13·1 answer
  • I have the requirements for Ace rank on Brainly but hasn't given me it yet. Does it just take longer than normal ranks or someth
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!