Search Results

Showing results 1 to 40 of 66
Search took 0.01 seconds.
Search: Posts Made By: twomers ; Forum: C++ and child forums
Forum: C++ 21 Days Ago
Replies: 4
Views: 373
Posted By twomers
I'd guess that what's holding up the program is printing to the console output, which is a slow process. Try writing to a file instead and it'll probably help with speed. Then see if you need to...
Forum: C++ 28 Days Ago
Replies: 9
Views: 403
Posted By twomers
You really should comment your code.
And on a side note check out cin.ignore(); after cin>>'ing.
Forum: C++ 30 Days Ago
Replies: 9
Views: 525
Posted By twomers
Uh.... what?
Forum: C++ 31 Days Ago
Replies: 6
Views: 349
Posted By twomers
cin.ignore() I think.
Forum: C++ 34 Days Ago
Replies: 11
Views: 546
Posted By twomers
>> sizeof( any pointer ) is always the same

>> That happens to be true for the garden variety PC of today, but it is not true as a generic statement.

Also, on the same system fat pointers are...
Forum: C++ Oct 16th, 2009
Replies: 3
Views: 524
Posted By twomers
All that changes with iterators that aren't 'int's is the template argument. http://www.cplusplus.com/reference/stl/vector/erase/
std::vector<randomType> myVec;
// Fill the vector with something...
Forum: C++ Aug 12th, 2009
Replies: 3
Views: 363
Posted By twomers
Someone asked something similar before in another forum (http://cboard.cprogramming.com/cplusplus-programming/107469-custom-loose-coupling-string.html) and you could do something like this.class...
Forum: C++ Aug 10th, 2009
Replies: 2
Views: 483
Posted By twomers
You could have it so the constructor requires a flag to ID the allocated item... so something like...class base {
public:
enum derrivableIDs {
idBase,
idOne,
idTwo
};
...
Forum: C++ Aug 8th, 2009
Replies: 6
Views: 345
Posted By twomers
Curious. You should use std::strings really...std::string strItoA(int number) {
std::ostringstream sin;
sin << number;
return sin.str();
}Though Narue may tell you to generalise...
Forum: C++ Jul 19th, 2009
Replies: 5
Views: 409
Posted By twomers
http://www.codeguru.com/forum/showthread.php?t=302806
First hit on google.
Basically, it extracts segments from a varaible, i.e. the higher or lower 16 bits.
Forum: C++ Jul 19th, 2009
Replies: 14
Views: 613
Posted By twomers
You should read about getline here, http://www.cplusplus.com/reference/iostream/istream/getline/

Personally, I'd use std::string-s and getline... #include <string>
#include <fstream>
#include...
Forum: C++ May 3rd, 2009
Replies: 5
Views: 339
Posted By twomers
Nah. You'll probably have to specialise the template, I'd say. Or overload a > operator, if you feel like it.
Forum: C++ May 2nd, 2009
Replies: 2
Views: 919
Posted By twomers
You can do what's called 'template specialisation' which will implement certain functions for a specific type, basically.
template<typename ty>
class myClass {
private:
ty var;

public:
...
Forum: C++ May 2nd, 2009
Replies: 4
Views: 516
Posted By twomers
Nope.
class thing {
private:
std::string str;

public:
thing(std::string _str)
: str(_str) {
}
std::string &getAttribute() {
Forum: C++ May 2nd, 2009
Replies: 4
Views: 516
Posted By twomers
aa is a pointer so you have to either dynamically allocate an instance of a, or set it to the address of an already instantiated instance, and call aa->getAttribute();. Alternatively doaa a;...
Forum: C++ Nov 22nd, 2008
Replies: 12
Views: 1,372
Posted By twomers
Well, there are two common ways you can represent complex numbers. One is a+ib where i is the root of -1, which is NOT -1. This is called the Cartesian (or rectangular) coordinate system. The second...
Forum: C++ Oct 15th, 2008
Replies: 3
Solved: Goto
Views: 904
Posted By twomers
goto (http://xkcd.com/292/)
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,534
Posted By twomers
I think you might have to return a reference/pointer to the stream. Though if it's a local variable you might have to return a dynamically allocated stream.
Forum: C++ Oct 1st, 2008
Replies: 7
Views: 1,631
Posted By twomers
>> Gee, what more do you want?
A clickable link would be nice. I don't want to have to copy and paste again, Salem!
Forum: C++ Sep 29th, 2008
Replies: 5
Solved: I/O Class
Views: 445
Posted By twomers
Because they do input or output. One could say the same about your FileHandler class. Meh. If you're only gonna be reading use ifstream, only writing use ofstream, if you're gonna be doing both use...
Forum: C++ Sep 29th, 2008
Replies: 5
Solved: I/O Class
Views: 445
Posted By twomers
If you use fstream you can both read and write to the strem. http://www.cplusplus.com/reference/iostream/fstream/ To be honest, I don't see the point in reinventing the wheel, but what the hey. Why...
Forum: C++ Sep 28th, 2008
Replies: 13
Views: 1,063
Posted By twomers
I made one list (mylist *l) and added an element to it (l->next = new mylist;), then compared items in the same list (iter->num > iter->next->num). iter is simply a pointer which points to the...
Forum: C++ Sep 28th, 2008
Replies: 13
Views: 1,063
Posted By twomers
Here's a very crude example which I haven't tested, but even if it doesn't work it'll show you how to go about the problem...struct mylist {
int num;
mylist *next;
};

int main( void ) {
...
Forum: C++ Sep 28th, 2008
Replies: 13
Views: 1,063
Posted By twomers
Maybe something like:nodo *p1, *p2;

p1 = List;
p2 = List->next;

if ( p1->key == p2->key ) // or p1->key == p1->next->key
// do this...Your problem is that you don't have a random access...
Forum: C++ Sep 25th, 2008
Replies: 4
Views: 633
Posted By twomers
In my opinion without some careful management it's asking for trouble. Why do you have to open it? Couldn't you do something like...std::[i/o]fstream fstr;

// ...

fstr.open( "file_name" );...
Forum: C++ Sep 22nd, 2008
Replies: 10
Solved: wierd warning
Views: 924
Posted By twomers
To understand the reasoning of this execute the following:int main() {
std::cout<< sizeof( unsigned long) << ", " << sizeof( unsigned short ) ;

return 0;
}Basically short*short = short, but...
Forum: C++ Sep 14th, 2008
Replies: 6
Views: 1,554
Posted By twomers
#include <iostream>
#include <vector>


int main( void ) {
// 4x5 (4 in x, 5 in y) array, containing -1
std::vector< std::vector<int> > vvint( 5, std::vector<int>( 4, -1 ) );

for( int...
Forum: C++ May 29th, 2008
Replies: 6
Solved: split data
Views: 957
Posted By twomers
So it'll say like 13 and you want to grab the next 13 characters? Will the length actually be wrapped in []? If ya have boost installed use boost::regex for the simplest way. You might be able to use...
Forum: C++ May 9th, 2008
Replies: 3
Views: 430
Posted By twomers
Maybe try a:
void printMe const {
// Code here...
}
Forum: C++ May 8th, 2008
Replies: 3
Views: 1,316
Posted By twomers
Forum: C++ May 6th, 2008
Replies: 5
Views: 561
Posted By twomers
Why do you need to cast or even make a and b? Just test num1 and num2:using namespace std;
int main()
{
while(1)
{
int num1, num2;
cout << "Insert two numbers" <<...
Forum: C++ Feb 28th, 2008
Replies: 5
Views: 686
Posted By twomers
Change:
if (guess< number, tries++)

to
tries++;
if (guess< number)
// ...
else if (guess>number )
//...You should only need to increment tries once.
Forum: C++ Feb 28th, 2008
Replies: 5
Views: 686
Posted By twomers
<iostream.h>, <stdlib.h> and <time.h> should not be used. Use instead <iostream>, <cstdlib>, and <ctime> In terms of <iostream.h> ... it's old. <iostream> is new and good. The other two are used in...
Forum: C++ Feb 26th, 2008
Replies: 3
Views: 687
Posted By twomers
Probably. That's the way I do it. You can also, if you wish, look into LoadLibrary (capitalisation?).
Forum: C++ Feb 26th, 2008
Replies: 3
Views: 687
Posted By twomers
#include <my_dll.h>
#pragma comment( lib, "my_dll.lib" )

int main() {
my_dll_function();
return 0;
}Should work with your IDE.
Forum: C++ Jan 28th, 2008
Replies: 9
Views: 952
Posted By twomers
Well, as nice as command != ('A' || 'B') looks it doesn't work like that. if( command != 'A' || command != 'B' ) is what you're looking for, but to be honest a straight out else should do -- it's...
Forum: C++ Jan 26th, 2008
Replies: 16
Views: 3,373
Posted By twomers
>> Could anybody help me with the code please?
Not unless you show some work.
But it's not that hard. There are two problems to overcome -- 1) filling the array 2) reading values from a file. Once...
Forum: C++ Jan 9th, 2008
Replies: 4
Views: 1,793
Posted By twomers
I really don't know what you mean. Do you want to save integers to file? Binder?
Forum: C++ Jan 1st, 2008
Replies: 10
Views: 1,277
Posted By twomers
I'm pretty sure you're making that up, or at least mistaking it.
Do you have a cin.ignore() or cin.get() or something before the function is called?

Also, you should use std::string to read in...
Forum: C++ Nov 19th, 2007
Replies: 4
Views: 1,973
Posted By twomers
One thing you could do is map out a directory. The structure could have the name of the directory, an array of sub-directories (which would possibly be a pointer to a new instance of the structure...
Showing results 1 to 40 of 66

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC