Forum: C++ Jun 16th, 2009 |
| Replies: 9 Views: 495 1. About C4716: didn't you know that double F_Ite() function must return double type value? And where is return anything-of-double_type in the function body? It's your code, you have wrote double... |
Forum: C++ Jun 15th, 2009 |
| Replies: 4 Views: 311 Don't worry, it's a small code ;)
Try to split functions into separate groups by themes (as usually, it's possible to do). Place every group in a separate cpp file (don't forget to add it to the... |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 412 Insert std::cin.ignore(1000,'\n'); after std::cin >> diameter; |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 412 >...why is this i cannot see anything wrong with my code...
Oh, this harmful Daniweb engine! I see 'area' in the OP snippet but area in the post #3 code ;)
By the way, change char area; to float... |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 412 Fill a glass with water (or what else) then drink, not vice versa ;)
Calculate a circle area AFTER its diameter request.
Output the area variable, not a wrong character literal 'area'... |
Forum: C++ Jun 15th, 2009 |
| Replies: 5 Views: 413 >I'm not quite sure what exactly you mean. I'm really new to C++. Can you explain a bit more clearly?
OK, let's come back to the class Path design. The class has a member function without... |
Forum: C++ Jun 15th, 2009 |
| Replies: 8 Views: 402 Well, your program crashed. It looks like a mere assertion, not a question.
Read This Before Posting: http://www.daniweb.com/forums/thread78223.html.
Never send exe files in attachments! |
Forum: C++ Jun 15th, 2009 |
| Replies: 5 Views: 413 What a wonderful teleportation of argv[3] to every class Path object do you want? If you have a "default" starting point of the Path object (probably it's the scArg member), provide this class for a... |
Forum: C++ Jun 15th, 2009 |
| Replies: 17 Views: 1,021 If so, mark this thread as solved ;) |
Forum: C++ Jun 14th, 2009 |
| Replies: 2 Views: 282 Better use std::string class:
#include <iostream>
#include <string>
using namespace std;
...
string day;
...
getline(cin,day);
if (day == "Mo") ... |
Forum: C++ Jun 14th, 2009 |
| Replies: 17 Views: 1,021 1. Well, reserve size (if no need in some postprocessing)
2. Tastes differs; for example, I prefer to return bool in such cases. I think, returned size if more useful than 0. Moreover, zero on... |
Forum: C++ Jun 14th, 2009 |
| Replies: 17 Views: 1,021 The wittingly wrong statement in OP code is delete buffer; - must be delete[]buffer;. Yet another defect: insufficient error check-up.
long GetFileSize(ifstream &file)
{
static const... |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 352 Your constructor variant with assignments has the same effect as mine. However as usually assignments in constructors (or even anywhere) are less effective than initialization with ctor-initializers... |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 352 In addition:
Change lines 40-45 in my code above to
/// more syntax sugar for lazies
const Suite
&Hearts = Suite::Hearts,
&Clubs = Suite::Clubs,
&Diamonds = Suite::Diamonds,
... |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 352 This part is so called ctor-initializer-list. In C++ it's a preferred way to initialize class members and the only method to pass constructor arguments to base class(es) constructors (the last... |
Forum: C++ Jun 12th, 2009 |
| Replies: 4 Views: 308 Are you sure that your method is not efficient?
Why?..
What's your efficiency criterion? |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 352 Of course, all possible in C++ ;)
That's an improvisation:
/// suite.h (class Suite definition)
class Suite
{
public:
Suite() {}
Suite(const Suite& suit):value(suit.value) {}
... |
Forum: C++ Jun 11th, 2009 |
| Replies: 16 Views: 745 >What evil being designed such a thing?!
Probably, it was the hardware architect's acute condition ;)
Many years ago... |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 481 >I want the minimal pointer because it is the left most node for my tree.
The leftmost node in the tree is not the same as the minimal pointer!
Moreover, a pointer value does not bear a relation to... |
Forum: C++ Jun 11th, 2009 |
| Replies: 16 Views: 745 >not many people will ever touch something like a 4-bit machine or any other sort of setup.
None the less there were supercomputers with 6-bits and 9-bits (or may be 12) bytes ;)
Moreover, I have... |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 481 >I dont want the data inside i want the pointer
Which pointer do you want (and why) - that's a question ;)
If you want the minimal pointer value ( why?! ) - you have it. What's a problem? Well,... |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 481 Probably you want a pointer which points to the minimal data value. In actual fact it's (as usually) senseless operation to compare pointer values. Moreover, the result of pointers comparison is... |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 560 Try to append LL suffix to long long constants. |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 556 >What do you mean? All memmove does is move memory. So even if you want to use your own class object, it should still work.
It's so simple. Suppose the object has a member which is a head of double... |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 556 William, we don't know base element type. If it's a class object (see OP), memmove can't move elements correctly! Moreover, remove class object means call destructor... |
Forum: C++ Jun 8th, 2009 |
| Replies: 6 Views: 366 Of course, the original post is extremely ill-formed.
However at least one defect arrests attention: sort_names function is wrong. Sorting loop index is out of range: names[j+1] refers to... |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 556 Too many problems on a single (and simple) program case is a symptom of bad design solution.
Evidently in that case you need different data structure. You want dynamically defined data structure... |
Forum: C++ Jun 8th, 2009 |
| Replies: 3 Views: 487 Initialization of class members (except static integral types):
class Ob // avoid all small letters names
{
public: // declare public then protected then private
Ob():name("Name") {} //... |
Forum: C++ Jun 7th, 2009 |
| Replies: 7 Views: 411 >the program encrypts the text at a rate of about 5000 characters per second on a 500mhz Intel Pentium 3 running windows xp pro.
It looks like an extremely low speed. I think that's a lower bound of... |
Forum: C++ Jun 4th, 2009 |
| Replies: 11 Views: 437 It's so interesting: what's your context? There is a wonderful context: Internet. For example:
http://www.cprogramming.com/tutorial/stl/stlmap.html
and lots of other links to std::map tutorials...... |
Forum: C++ Jun 4th, 2009 |
| Replies: 11 Views: 437 It's so easy: use std::map<std::string,planet>. |
Forum: C++ Jun 3rd, 2009 |
| Replies: 4 Views: 250 1. Probably you mean doesn't promote -1 to unsigned int...
2. All this happens in int a = (int)-1 * x. The funny part is: (int)-1 is the same as -1 because an integer literal already (and always)... |
Forum: C++ Jun 3rd, 2009 |
| Replies: 4 Views: 954 Try to understand the standard compilation process logic.
Simplified translation process description:
1. Every .cpp file is processed separately (as if no other cpp files)
2. Preprocessor... |
Forum: C++ Jun 2nd, 2009 |
| Replies: 6 Views: 686 Place your struct type definition in .h file:
struct Points {
int xCoordinate;
int yCoordinate;
int zCoordinate;
};
... global functions prototypes
Include this .h file in all... |
Forum: C++ Jun 2nd, 2009 |
| Replies: 4 Views: 208 And where are data declarations?
;)
Please, Read This Before Posting: http://www.daniweb.com/forums/thread78223.html |
Forum: C++ Jun 2nd, 2009 |
| Replies: 4 Views: 208 |
Forum: C++ Jun 1st, 2009 |
| Replies: 2 Views: 735 Of course, you can't access protected method in main! Only member functions of derived classes can access protected members.
Re-read your C++ textbook... |
Forum: C++ Jun 1st, 2009 |
| Replies: 3 Views: 549 May be it helps (see modf function: split integer and fractional parts):
/**
* 2008-10-01 Beta version. No warranties...
* Rounding functions freeware mini-package.
* About rounding forms... |
Forum: C++ May 31st, 2009 |
| Replies: 6 Views: 354 Didn't you familiar with logical not operator?
if (!*fileName)
// or
if (fileName[0] == '\0')
// or
if (strlen(fileName) == 0)
By the way, fileName == "" is equal to false in all cases.... |
Forum: C++ May 31st, 2009 |
| Replies: 6 Views: 354 Keep it simple:
fileName[0] = '\0';
// or even
*fileName = 0;
// to test:
if (*fileName) { // non-empty
;) |