Forum: C++ Apr 29th, 2009 |
| Replies: 3 Views: 637 I think it would be more useful if one could pass the string into a method and have it return the number of question-marks found (as an unsigned int, or in extraordinary cases an unsigned long int). |
Forum: C++ Nov 28th, 2008 |
| Replies: 8 Views: 786 void TestVector(Vector<double> v)
{
}
int main()
{
Vector<double> pd(5.6,3.4,2.4);
// use the cast operator works if copy ctor is not defined
Vector<float> pf = pd; |
Forum: C++ Nov 26th, 2008 |
| Replies: 9 Views: 2,576 You know, I've been wondering about this for awhile now myself.
Honestly you can probably get away with making some kind of regex or key to "compress" files with given values.
For example lets... |
Forum: C++ Nov 22nd, 2008 |
| Replies: 3 Views: 448 There is hope!
Use fmod to resolve the modulus between two doubles
#include <iostream>
using std::cin;
using std::cout; |
Forum: C++ Nov 22nd, 2008 |
| Replies: 5 Views: 1,166 Hmm, try changing char to unsigned (if it exists @_@ )
-Alex
Edit: I am really tired #_#
I didn't realize I made the array back-asswards XD
XP |
Forum: C++ Nov 22nd, 2008 |
| Replies: 5 Views: 1,166 You can use the bool array as a "bit-position" array for the representation of a char.
#include <iostream>
using std::cout;
using std::cin;
using std::endl; |
Forum: C++ Nov 20th, 2008 |
| Replies: 2 Views: 305 That means you are literally treating something that isn't an lValue as an lValue.
For example if a method doesn't return a reference to something, its possible that attempting to treat the method... |
Forum: C++ Nov 20th, 2008 |
| Replies: 14 Views: 1,158 Rep-worthy! XD
It's too bad I can't give you any more rep today @_@
-Alex |
Forum: C++ Nov 20th, 2008 |
| Replies: 14 Views: 1,158 I don't know why... but I found the first post amusing XD
But I'm laughing with you Beast! I promise! O_O
-Alex |
Forum: C++ Nov 17th, 2008 |
| Replies: 6 Views: 1,234 My apologies.
Apparently I missed the portion of your first statement "I cannot use anything else, rules are rules." Please forget my previous comment. |
Forum: C++ Nov 16th, 2008 |
| Replies: 6 Views: 1,234 You may want to consider this process--
-Pull in lines from target read file and store them in a stack<string>
-pop strings from stack and write them to file
That's if the strings need to be... |
Forum: C++ Oct 31st, 2008 |
| Replies: 10 Views: 1,337 Here's something I managed to whip up thanks to your logic--
#include <iostream>
#include <string>
#include <vector>
using std::cout;
using std::cin;
using std::endl; |
Forum: C++ Oct 28th, 2008 |
| Replies: 8 Views: 934 I thought I had the specs right until you said down-right instead of up-right in your 2nd paragraph.
Maybe a picture will be helpful?
Also, what are you using to graphically display your... |
Forum: C++ Oct 19th, 2008 |
| Replies: 4 Views: 1,166 I personally consider code in a Driver Program to be cleaner when the logic of main is known before anything else.
Also, function declarations make code more readable because you know of the... |
Forum: C++ Oct 19th, 2008 |
| Replies: 4 Views: 1,166 void printmovie (movies_t movie);
Is a function declaration.
The definition exists elsewhere in the same file.
Short/Simple reason: C++ can be very linear. If you comment out the function... |
Forum: C++ Oct 18th, 2008 |
| Replies: 3 Views: 1,154 In C++, you can declare a function, constructor, or operator to accept a type by reference and not value.
For example, the declaration of the function--
void foo(int); |
Forum: C++ Oct 17th, 2008 |
| Replies: 4 Views: 398 You can't declare a method within another method O_O
You'll have to pull all of your other methods (add, subtract etc) outside of the definition of your simp method. Your simp method can have the... |
Forum: C++ Oct 17th, 2008 |
| Replies: 4 Views: 398 It never hurts to include your code (provided it's not too long! O_O).
Just be sure to use code tags @_@
-Alex |
Forum: C++ Oct 16th, 2008 |
| Replies: 2 Views: 1,108 I'd like to apologize...
the previous example can be forgiven for not implementing Node deletion (since OP has it defined), but can't be forgiven for forgetting appropriate Node declarations in... |
Forum: C++ Oct 16th, 2008 |
| Replies: 2 Views: 341 That would be the ideal way, but also a lot slower.
Question for the original poster - what is a word? Is a word like the definition of a Windows WORD, or is it any 32bit (unsigned) int, or what... |
Forum: C++ Oct 15th, 2008 |
| Replies: 2 Views: 1,108 You can't make a typedef out of an incomplete type, so the following would be illegal if NodeType is generalized--
typedef NodeType* NodePtr;
struct NodeType
{
ItemType item;
... |
Forum: C++ Oct 13th, 2008 |
| Replies: 8 Views: 571 Here's an example of encapsulating a 2D vector and emulating the behavior or a 2D vector through a class--
#include <iostream>
#include <vector>
#include <cmath>
using std::cin;
using... |
Forum: C++ Sep 30th, 2008 |
| Replies: 19 Views: 2,031 Correct me if I'm wrong, but doesn't the cavet ^ symbol in C++.NET mean that the type is actually a pointer?
List1.Add(Vec1()); looks fishy... Vec1 is a pointer-type, so doesn't that mean you need... |
Forum: C++ Sep 25th, 2008 |
| Replies: 7 Views: 557 I had to edit what you posted... the indentation got to me--
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <sstream>
using namespace std; |
Forum: C++ Sep 24th, 2008 |
| Replies: 10 Views: 855 Not quite. It would be valid if your array consisted of const char* values because strings accept const char* (and also chars) as a constructor argument via the ADT implementation in C++. Since the... |
Forum: C++ Sep 24th, 2008 |
| Replies: 4 Views: 866 Is there a reason you are using '/n' instead of '\n' ?
Also, is there a defined expression for a string being equivalent to a char? If not then you could try line != "\n" instead, though I don't... |
Forum: C++ Sep 24th, 2008 |
| Replies: 3 Views: 1,771 I do not recall the arrow keys having a virtual key code associated with them from standard C++.
I think the only way to do it is through the OS interpretation of the virtual key code of the... |
Forum: C++ Sep 17th, 2008 |
| Replies: 9 Views: 791 Correct me if I'm wrong, but you are using the .NET Frameworks with C++, are you not?
If you are, have you tried looking up information on individual Components in the .NET Frameworks the way you... |
Forum: C++ Sep 16th, 2008 |
| Replies: 14 Views: 1,576 Did you try using C:/config_file_directory instead?
It may be that the \c is being mistaken for a special escape character, and not exactly two separate characters.
Edit: Also, for... |
Forum: C++ Sep 16th, 2008 |
| Replies: 17 Views: 1,524 Oh, and in case it hasn't been addressed my tokenizer makes tokens out of substrings, not char's. |
Forum: C++ Sep 16th, 2008 |
| Replies: 17 Views: 1,524 Split the lines up into words and place the words for a corresponding line into a vector.
For example, vector<string> a has elements "I", "believe", "in", "you" and vector<string> b has elements... |
Forum: C++ Sep 16th, 2008 |
| Replies: 17 Views: 1,524 Oddly enough I was working away at a tokenizer. I think that my snippet (http://www.daniweb.com/code/snippet954.html) might be helpful, but maybe not if this is an assignment.
If it is an... |
Forum: C++ Sep 15th, 2008 |
| Replies: 6 Views: 1,081 Works fine with VC++ 2005/2008 |
Forum: C++ Sep 14th, 2008 |
| Replies: 6 Views: 1,446 I'm pretty sure you meant 25 (5*5), but I believe you get the idea.
Have fun =) |
Forum: C++ Sep 14th, 2008 |
| Replies: 6 Views: 1,446 Vectors have an overloaded Constructor that allows two arguments...
I do believe, in that scenario, the first argument is the initial size and the second is the default value for all values in the... |
Forum: C++ Sep 11th, 2008 |
| Replies: 5 Views: 1,106 Narue explains it best here (http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx). |
Forum: C++ Sep 10th, 2008 |
| Replies: 9 Views: 971 Classes can be used for many things...
The Programming perspective:
-Restricting access to encapsulated data/ standing in for the same type (Proxy)
-Abstractions for future data (Strategy,... |
Forum: C++ Sep 10th, 2008 |
| Replies: 5 Views: 1,106 Try creating a Red-Black Tree.
See attached. |
Forum: C++ Sep 9th, 2008 |
| Replies: 6 Views: 486 You were nearly right! Here's a correction--
#include <iostream>
#include <fstream>
using namespace std;
const int MAX = 30;
struct node |
Forum: C++ Aug 9th, 2008 |
| Replies: 6 Views: 1,609 Here's a working example--
#include <iostream>
#include <vector>
class MyClass{
public:
std::vector< void(MyClass::*)()> ptmf_Vector; |