Forum: C++ Jun 16th, 2009 |
| Replies: 8 Views: 481 What for this overcomplicated unclear code? What's a programming case where this nightmare required?
This thread was started from a very suspicious-looking remark The compiler forces me to do a... |
Forum: C++ Jun 16th, 2009 |
| Replies: 9 Views: 446 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 16th, 2009 |
| Replies: 6 Views: 277 The most natural place for structures without tags is typedef declaration (it's the only place I've used anonymous structs ;)):
typedef struct
{
...
} Record;
...
Record rec;
Record*... |
Forum: C++ Jun 16th, 2009 |
| Replies: 8 Views: 481 Apropos, your fix_name is wrong. It does nothing (except memory leak).
You modify dynamically allocated copy of the string argument then assign the pointer to the parameter (but not to the... |
Forum: C++ Jun 16th, 2009 |
| Replies: 3 Views: 226 And yet another question to OP:
Why you are starting a new thread on the same problem?
Orphaned thread:
http://www.daniweb.com/forums/thread197527.html
;) |
Forum: C++ Jun 16th, 2009 |
| Replies: 5 Views: 204 No a proper constructor of the class SipDialogPublish.
Check up class SipDialogPublish definition and types of constructor arguments in the line #343. Probably this constructor was declared but not... |
Forum: C++ Jun 16th, 2009 |
| Replies: 3 Views: 226 Yet another tip:
while (infile) // wrong loop!
{
getline(...);
... >> ...
i++
}
See what happens if the file is empty or after the last line reading: |
Forum: C++ Jun 15th, 2009 |
| Replies: 1 Views: 248 Try to adopt this improvisation:
const size_t allbut = std::numeric_limits<int>::max();
bool overStep(std::istream& in)
{
char c;
while (in.ignore(allbut,'S')) {
do
... |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 701 Sorry, I have not noticed that you are in ubuntu environment...
It's not a problem in the Visual Studio debugger. |
Forum: C++ Jun 15th, 2009 |
| Replies: 4 Views: 297 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: 701 It's not an error at all. It's a simple info message. Fill the difference. |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 384 Insert std::cin.ignore(1000,'\n'); after std::cin >> diameter; |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 384 >...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: 5 Views: 504 >...because if you just put a and b without quotes, the compiler will think that you are using the variables a and b.
That's exactly what OP intends to do ;) |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 384 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: 8 Views: 999 After that place all system header includes in StdAfx.h (and remove them from .cpp files (after #include "StdAfx.h")... |
Forum: C++ Jun 15th, 2009 |
| Replies: 5 Views: 370 >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: 385 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: 370 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: 2 Views: 243 >I have found lots of ways to do this if I want all of the elements of the string but not how to do it when I only want certain parts.
What's a funny statement... If you can get all elements (by the... |
Forum: C++ Jun 15th, 2009 |
| Replies: 6 Views: 292 Of course, it's not a stupid question but it's impossible to answer in a few words.
Look at
http://www.is.pku.edu.cn/~qzy/cpp/vc-stl/templates.htm... |
Forum: C++ Jun 15th, 2009 |
| Replies: 17 Views: 921 If so, mark this thread as solved ;) |
Forum: C++ Jun 14th, 2009 |
| Replies: 2 Views: 253 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: 3 Views: 297 Look at DISLIN (free for personal use):
http://www.mps.mpg.de/dislin/ |
Forum: C++ Jun 14th, 2009 |
| Replies: 17 Views: 921 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: 921 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 13th, 2009 |
| Replies: 5 Views: 224 See what a class of that sort (std::string surrogate) must have:
class Testing
{
public:
Testing();
Testing(const char*);
Testing(const Testing&); // copy constructor
Testing&... |
Forum: C++ Jun 13th, 2009 |
| Replies: 3 Views: 523 Right direction but lots of defects in OP code.
The OP title does not bear a relation to the real OP problems.
Think about:
// Never fix array size in a function!
int getLargest(const int* a,... |
Forum: C++ Jun 12th, 2009 |
| Replies: 5 Views: 273 There is a very strange syntax construct in your code:
switch (dom_destination)
do {
case 1:
Of course, it's an error, but syntactically switch statement in C and C++ looks as... |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 331 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: 331 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: 331 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: 297 Are you sure that your method is not efficient?
Why?..
What's your efficiency criterion? |
Forum: C++ Jun 12th, 2009 |
| Replies: 6 Views: 331 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: 362 >...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: 776 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: 362 >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: 711 >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: 7 Views: 556 The new-line character is defined in C, it's '\n'. The fgets standard library function retains a single new-line character from text mode streams only, but...
be careful: |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 440 >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... |