Forum: C++ Jun 16th, 2009 |
| Replies: 9 Views: 543 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: 317 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: 420 Insert std::cin.ignore(1000,'\n'); after std::cin >> diameter; |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 420 >...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: 420 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: 433 >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: 415 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: 433 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,110 If so, mark this thread as solved ;) |
Forum: C++ Jun 14th, 2009 |
| Replies: 2 Views: 293 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,110 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,110 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: 362 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: 362 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: 362 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: 320 Are you sure that your method is not efficient?
Why?..
What's your efficiency criterion? |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 362 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 12th, 2009 |
| Replies: 6 Views: 380 >...if you want to be a pedant...
To make distinctions between static, automatic and dynamic attributes - is it too pedantic for you?
;) |
Forum: C Jun 12th, 2009 |
| Replies: 8 Views: 874 In C you can assign void* type pointer value to the pointer of any type without casting. So simply declare a proper type pointer and set it to the buffer:
char* pchar = buf_ptr;
char* ptr = pchar... |
Forum: C Jun 12th, 2009 |
| Replies: 6 Views: 380 >short answer: static arrays are allocated when the function is called...
Short remark: static arrays are allocated before the first call of the function. However no static arrays in OP snippet.... |
Forum: C++ Jun 11th, 2009 |
| Replies: 16 Views: 758 >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: 501 >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: 758 >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: 501 >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: 501 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 10th, 2009 |
| Replies: 18 Views: 882 >More random calls will tend to dilate the variance.
The variance of... what? We didn't estimate random sequence parameters in that case so the variance (or other moments) does not bear a relation... |
Forum: C Jun 9th, 2009 |
| Replies: 18 Views: 882 A day ago csurfer's algorithm solved the problem. That's "pipelined" version:
int i, j = rand()%20;
for (i = 0; i < 20; i++)
array[i] = (i != j)*(rand()%9 + 1);
In addition:... |
Forum: C Jun 9th, 2009 |
| Replies: 14 Views: 875 |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 598 Try to append LL suffix to long long constants. |
Forum: C++ Jun 8th, 2009 |
| Replies: 13 Views: 567 >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: 567 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: 369 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: 567 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: 5 Views: 551 Why strncat? Make a single (expected) string by a single snprintf call. What's a problem? |
Forum: C++ Jun 8th, 2009 |
| Replies: 3 Views: 519 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: 14 Views: 875 The second argument type is a pointer to a pointer to FILE type.
Didn't you understand what's a pointer?
Evidently this function returns FILE* pointer via this argument. What's a strange... |
Forum: C Jun 7th, 2009 |
| Replies: 1 Views: 354 absread:
What's it: ancient TC non-standard function to read a sector from the HD in native DOS environment.
Usage: forget as soon as possible. |
Forum: C++ Jun 7th, 2009 |
| Replies: 7 Views: 428 >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 7th, 2009 |
| Replies: 11 Views: 666 Excuse me, siddhant3s: I have not seen your post above! :(
No need in my post now. |
Forum: C Jun 7th, 2009 |
| Replies: 11 Views: 666 According to the C and C++ standards
int array[....];
array[-2] - wrong expression, because array-2 points to inexisting array element (the only exception: pointer to the 1st element after... |