i need help in writing c++ program by using classes ????

Recommended Answers

All 8 Replies

This is a very generic question, don't count on much help until you provide some specifics and give us an example of what you've done.

This is spelled out quite clearly in the homework-related announcement at the top of the thread listing.

What do you know about classes?

classes is similar to structure it allows bundling of related variables and member function , also it includes objects
also by using classes you can control the access to member by declare it in to either public or private ...
so what else do you want me to explain about classes

so what else do you want me to explain about classes

I don't want you to explain one single thing more about classes! Not One!!!

What I want you to do is create a class to model a box and calculate its volume. Then instantiate an object of this class and calculate the volume of an instance of this class with sides 2, 3, and 4. You can use ints. And I want it done within 24 hours!!!

And I just decided I'm not going to go easy on you!

I also want the program written in C first without classes, and then in C++. Then I want a full elaboration on the differences and why the C++ version might be better!!! And just to show you that I'm a nice guy, I'll add 12 hours to the time limit.

Please be more specific. Classes are a complex concept of programming.
You can get a whole bunch of information about classes just by google-ing it.

I don't want you to explain one single thing more about classes! Not One!!!

What I want you to do is create a class to model a box and calculate its volume. Then instantiate an object of this class and calculate the volume of an instance of this class with sides 2, 3, and 4. You can use ints. And I want it done within 24 hours!!!

And I just decided I'm not going to go easy on you!

I also want the program written in C first without classes, and then in C++. Then I want a full elaboration on the differences and why the C++ version might be better!!! And just to show you that I'm a nice guy, I'll add 12 hours to the time limit.

ohhh who told you that i need help from yaaa ???????
did i ask you for help???

Please be more specific. Classes are a complex concept of programming.
You can get a whole bunch of information about classes just by google-ing it.

well, actually im still new in this issue i just took a lecture about classes only before 2 weeks , and i have aquestion in my h.w that i couldn't solve because of that i asked for a help

You're not getting much help because you've asked a VERY generic question.

Ask a better (read "more specific") question on your issue and show us an example of what you've tried. Until then, we can't help you because we don't know HOW to help you.

I'll give an example of what I've been working on for my C++ class: consider a program to process polynomials (add, subtract, multiply etc).

I created a class called Polynomial. From within this class, I had private variables of an array to hold the coefficients of a polynomial, as well as the degree (aka x^2+x+1 is degree=2). I had member functions that would do the processes (add, subtract, multiply) that I defined just like a normal function, but including the private variables.

Within the main function, I could create different objects of the class, aka create different polynomials. They are declared just like a variable (well given how you establish your constructor, look that up) so like this
"Polynomial poly1;"
From there I can use any of the functions to compute what I want simply by calling them in context to a polynomial I created.
"poly1.add();"
or
"poly1.subtract();"

So in essence, classes are used to create different instances of objects that you want to use within your main function.

I hope this helps somewhat.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.