0
``//this program show the implementation of a sigle class
#include<iostream>
#include<conio.h>
using namespace std;
class Example //class is reserved keyword and "Example is the name of class
{
public: 
int first_value;
int second_value; //these are data member of class with "public access modfire"
void setValue(int f,int s) //here i used setter for  set value
{
first_value=f;
second_value=s;
}
void show()// this is called inline function also member function becouse it is inside the class
{
cout<<"first_value="<<first_value<<endl;
cout<<"second_value="<<second_value<<endl;
}
};
int main()
{
Example obj; //obj object of the class
obj.setValue(15,25);// set the value of set function by using dot(.) opreator 
obj.show();
getch();
return 0;
}

**Output**

first_value=15
second_value=25;Inline Code Example Here
4
Contributors
4
Replies
25
Views
8 Months
Discussion Span
Last Post by rproffitt
0

Is there a question?

Guessing it was intended as a tutorial or a code sample and the OP didn't flag it as such.

Just a guess since the OP doesn't say so explicitly other than in the title, which is insufficient in my view.

OP, don't be afraid to add a few sentences in English explaining what you're doing and why. As far as the quality of the code, I didn't read the code. Why didn't I read it? Formatting. It's essential that you make your code readable. Google "C++ code beautifer", copy/paste your unformatted code into one of the results, and see how much easier it is to read...

This one for example... https://www.tutorialspoint.com/online_c_formatter.htm

Yields this...

//this program show the implementation of a sigle class
#include<iostream>
#include<conio.h>
using namespace std;
class Example //class is reserved keyword and "Example is the name of class
{
public:
    int first_value;
    int second_value; //these are data member of class with "public access modfire"
    void setValue(int f,int s) //here i used setter for  set value
    {
        first_value=f;
        second_value=s;
    }
    void show()// this is called inline function also member function becouse it is inside the class
    {
        cout<<"first_value="<<first_value<<endl;
        cout<<"second_value="<<second_value<<endl;
    }
};
int main()
{
    Example obj; //obj object of the class
    obj.setValue(15,25);// set the value of set function by using dot(.) opreator
    obj.show();
    getch();
    return 0;
}

Now the above code is worth reading and learning from or offering critiques or whatever you are looking for (again, stick a few sentences in there to make it obvious what you're looking for and the mods will probably help you move it to the right spot if need be).

0

When the office asked me for better formatted code I asked them to pick one out of https://en.wikipedia.org/wiki/Indentation_style

Only eight styles but what did they do? Create yet another style. Even went so far as to task someone to write the company code style book.

Result. One crazy person (the one that had to write the style) and a few less employees as what happens when war breaks out.

Me? Just nodded and keep coding. Those that got hung up on style no longer work there. Fired for non-production or other reasons.
The perils of being in a commercial setting. In a more academic setting the ones the took on style over production would likely have survived.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.