Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
4
votes
C++ matrix class
Summary
Your resource management is broken.
You have not implemented the rule of 3 or 5 and so you are going to leak and/or do double deletes. So let's concentrate on the Matrix part rather than resou …
12
votes
U.S. Postal Service zip code and bar code class
Bad comments
//validate bar code format
bool validateBar(std::string) const;
//convert integer zip code to string bar code
std::string zipToBar(int) const;
//convert string bar code to …
5
votes
Accepted
OOP elevator design evaluation
First the C++ code:
class elevator{
liftbox box;
class liftbox{
elevator ele;
This is not going to work as you expect it.
Each class contains an object of the other type means that both will …
1
vote
Accepted
Online book reader system
Design
Well your code seems to do a lot more than your initial design.
So first of I would simplify all the code to do what the design is not do everything that you can imagine that the system needs t …
5
votes
Capturing temperature information for a patient
Your interface is BAD
float Temperature::setFaren(){
float faren = newTemp+32;
return faren;
}
float Temperature::setCels(){
float celsi = newTemp-32;
return celsi;
}
So I can call t …
1
vote
Is usage of friend class appropriate in this case?
Personally I prefer objects that know how to read/write themselves from a stream.
class Pod
{
public:
Pod() // Should always have some form of constructor
: angle …
10
votes
nonstd:: non standard classes
Standard classes and derivation
If a class does not have a virtual destructor it is not supposed to be derived from. Before we got the finally key word this was the indicator you were supposed to use …
4
votes
Am I designing this right ? I feel like it is extremely hairy
This needs a lot of work to bring it up to current standard practices. Currently I would not consider this C++ code, but rather C code that happens to use some C++ features.
All Upper Case Identifier …
4
votes
Leetcode 1603. Design Parking System
Observation
You can simplify this using arrays.
You don't need two numbers for each type (max and current). Simply track the number of open spots (per type) and count down.
if you are not using arrays …
7
votes
Casting base to derived class according to a type flag
Is casting a base class object to a derived class object given a type flag a good programming design?
Usually no.
It usually indicates a badly defined interface in your base class.
A better way …
2
votes
Object oriented approach to Dijkstra's algorithm
General Comments
You don't do memory management correctly anywhere
There is already heap functionality in the standard library.
There is also a priority_queue that is based on this heap functionalit …
15
votes
Weapon and Hero classes
@Toby Speight describes how it should probably be done.
But I want to describe what is happening in your case so that you understand the concept of copy construction and assignment.
The problem is tha …
4
votes
C++ implementation of the observer design pattern
Design Review
Ownership
One of the advances of C++ over is C is ownership semantics. We understand who owns an object (and thus who is responsible for destroying the object). We do this by using a s …
9
votes
Accepted
C++ implementation of the Command Pattern
Virtual Destructor
If a class has virtual methods it should also have a virtual destructor. Now this is only important if you destroy a class from a pointer to the base class. Since your code leaks a …
3
votes
Accepted
MNIST Neural network in C++
This is all subjective:
But I would prefer if the constructor set up the NeuralNet and was ready to go. Once the object there is no need to call extra functions like initializeLayers() or setHyperPar …