473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

what is the main function of class in c++?when we have to use class ?

will u explain more about the class
Jan 5 '10 #1
3 1389
Dheeraj Joshi
1,123 Expert 1GB
Please start reading the OOP concept first. You will get a clear picture.
Google and find more about classes..

Regards
Dheeraj Joshi
Jan 5 '10 #2
newb16
687 512MB
The main function of C++ class is being an implementation of 'object' paradigm of OOP. We _have_ to use it when usage of classes is required by external framework built upon classes itself.
Jan 5 '10 #3
weaknessforcats
9,208 Expert Mod 8TB
There are no classes in C++.

All C++ has are structs.

The C++ "class" is implemented as a struct.

This:

Expand|Select|Wrap|Line Numbers
  1. struct MyStuff
  2. {
  3.      private:
  4.          int data;
  5.      public:
  6.          void SetData(int);
  7.          int   GetData();
  8.          ///etc...
  9. };
is exactly the same as:

Expand|Select|Wrap|Line Numbers
  1. class MyStuff
  2. {
  3.      private:
  4.          int data;
  5.      public:
  6.          void SetData(int);
  7.          int   GetData();
  8.          ///etc...
  9. };
That is, as long as you specify our member access as public/private/protected, there is no difference between a struct and a class.

There is one difference when you do not specify the member access. The default access for a struct will be public whereas the default access for a class will be private.

I suggest you expand your research into how to implement encapsulation.
Jan 5 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
2
by: marco | last post by:
the problem: I use a typedef inside a class template, than I use this type (dim_v<N1>::Type) to define the argument of a template function f but when I call this function from main, the compiler...
11
by: Micha | last post by:
Hello there, I think I've run into some classic c++ pitfall and maybe some of you guys can help me out. For my project I will need to use matrices and vectors and so I decided to implement them...
4
by: Charles Law | last post by:
I've been using monitors a bit lately (some of you may have heard ;-) ) and then up pop Manual and AutoResetEvents , and they look for all the world like the same thing. Are they...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
6
by: PengYu.UT | last post by:
Hi, I couldn't see what is wrong with the following program. Would you please help me? Thanks, Peng g++-3.4 -MM -g main.cc .dep
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
2
by: thuythu | last post by:
Please help me.... I used and Javascript to view the data. But when i click button open a popup windows, then select data and click save button. The popup close and return the main page, but the...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.