Search Results

Showing results 1 to 40 of 295
Search took 0.04 seconds.
Search: Posts Made By: vijayan121
Forum: C++ Nov 13th, 2008
Replies: 3
Views: 700
Posted By vijayan121
> declare it as private and just leave an empty implementation?
ideally, declare it as private and do not define it.

> Is this common/useful?
useful, yes. common, not all that much.
if there is...
Forum: C++ Nov 4th, 2008
Replies: 3
Views: 477
Posted By vijayan121
this is broken when C is a const container.
c.begin() and c.end() returns objects of type C::const_iterator.

in C++98 you would have to do something like
template < typename CNTR > struct...
Forum: C++ Sep 28th, 2008
Replies: 11
Views: 1,211
Posted By vijayan121
this is nothing specific to constructors or passing parameters to functions.
it is just the application of the C++ rules for resolving a call to an overloaded function.
#include <iostream>

void...
Forum: C++ Aug 29th, 2008
Replies: 7
Views: 1,108
Posted By vijayan121
you can answer this yourself if you write a small test program and run it. for example:
#include <iostream>

struct A
{
A() { std::cout << "A::default constructor\n" ; }
A( const A& ) {...
Forum: C++ Aug 28th, 2008
Replies: 3
Views: 543
Posted By vijayan121
> Does it make sense to write a virtual method in the templated base class
> in order to force derived classes to have an appropriate addelement() method?
no. the polymorphism provided by...
Forum: C++ Aug 28th, 2008
Replies: 3
Views: 543
Posted By vijayan121
if you absolutely need a base class Chart (with virtual functions), a hack would be to overload the AddElement function.

i would prefer using templates for your containers as suggested by Narue in...
Forum: C++ Aug 23rd, 2008
Replies: 3
Views: 1,777
Posted By vijayan121
> Is there any real different between using an union between two types and a reinterpret_cast between two types
yes, there are quite a lot of differences.
a union reinterprets the layout of memory...
Forum: C++ Aug 9th, 2008
Replies: 6
Views: 790
Posted By vijayan121
the typical work around (as exemplified by the standard library containers and function objects) is to have the generic type announce dependent types via suitable typedefs.
#include <vector>...
Forum: C++ Jul 17th, 2008
Replies: 8
Views: 820
Posted By vijayan121
simulating long division by hand (shift and subtract):
http://courses.cs.vt.edu/~cs1104/Division/ShiftSubtract/Shift.Subtract.html
Forum: C++ Jul 17th, 2008
Replies: 8
Solved: Alignement
Views: 804
Posted By vijayan121
> The structs are padded so that no padding occurs when we create an array of them,
> like with a scalar variable because if the compiler padded the struct when it created the
> array it wouldn't...
Forum: C++ Jul 17th, 2008
Replies: 8
Solved: Alignement
Views: 804
Posted By vijayan121
struct align1
{
double a;
char b;
int c;
short d;
};

> why the compiler pads the structure in the end?
Forum: C++ Jul 17th, 2008
Replies: 8
Views: 820
Posted By vijayan121
#include <iostream>
#include <limits>

// addition can be done using bitwise xor
// with adjustments for carry bits
unsigned int plus( unsigned int first, unsigned int second )
{
unsigned...
Forum: C++ Jul 11th, 2008
Replies: 2
Views: 485
Posted By vijayan121
from http://www.gnu.org/software/make/manual/make.html#Implicit-Rules
Forum: C++ Jul 5th, 2008
Replies: 13
Views: 1,418
Posted By vijayan121
> If you're never going to use a custom allocator, it doesn't make any sense to do that extra work.
the fundamental problem with your code is not that it does not cater for a custom allocator for...
Forum: C++ Jul 5th, 2008
Replies: 13
Views: 1,418
Posted By vijayan121
> typename is not followed by a name, which I find confusing
since the intent is to declare a template template type (ttp), the identifier following typename is just a place-holder (like the name...
Forum: C++ Jul 2nd, 2008
Replies: 4
Views: 1,763
Posted By vijayan121
> So I could write something like this:
...
no, you can't. you need to write something like:
std::size_t max = 0; // Number set by user at execution
// ...
long (*pBigArray)[100][100] = new long...
Forum: C++ Jun 27th, 2008
Replies: 4
Views: 1,470
Posted By vijayan121
> ...maybe the array is automatically cleared from memory when the application closes...

right, provided your program is running under an os ( like unix, windows, linux ... ) which gives a...
Forum: C++ Jun 22nd, 2008
Replies: 12
Views: 1,005
Posted By vijayan121
case 1 : float hipvalley(); // this is the Hip/Valley choice.
that is merely a declaration of the function hipvalley.
to invoke the function (and ignore its result), write
case '1' : hipvalley();...
Forum: C++ Jun 22nd, 2008
Replies: 8
Views: 843
Posted By vijayan121
#include <cstdlib>
#include <string>

inline char random_digit() { return '0' + std::rand() % 10 ; }

inline std::string random_pin( std::size_t ndigits )
{
std::string pin ;
for(...
Forum: C++ Jun 21st, 2008
Replies: 9
Views: 924
Posted By vijayan121
or
// ...
int Strength = 5 ;
int Intelligence = 2 ;
int Agility = 3 ;
int Defense = 3 ;
int Health = 10 ;
int Level = 1 ;

for(;;)
Forum: C++ Jun 16th, 2008
Replies: 9
Views: 1,354
Posted By vijayan121
> ...139 files, with 16,000 lines of code...
> ...So how do I start to disect messy code that is not documented and not written by me?
> How does somebody look at code and start to make sense of...
Forum: C++ Jun 7th, 2008
Replies: 14
Views: 1,926
Posted By vijayan121
> 3.6 * vector_a; why can I not implement this binary operator as a member operator of a class Vector?
you can, if the class Vector is your own class.
if not ( for example for standard containers...
Forum: C++ Jun 1st, 2008
Replies: 3
Views: 2,552
Posted By vijayan121
sortValues is not a template member. you need to modify DO_SORT

#define DO_SORT(varName, a, b, c, d) (*(varName)).sortValues(a, b, c, d)

when you are sorting an array of char, use MySort<char>...
Forum: C++ May 29th, 2008
Replies: 4
Views: 421
Posted By vijayan121
for( int i=0 ; i<10 ; ++i )
numb2[i] = i%2 == 0 ? (i/2)*5 : i ;
Forum: C++ May 27th, 2008
Replies: 12
Views: 1,947
Posted By vijayan121
> an algorithm better than FFT for getting large numbers(of the order of 10 power 30 or more)?
FFT multiplications are efficient when numbers are very large. the other popular multiplication...
Forum: C May 16th, 2008
Replies: 8
Views: 1,730
Posted By vijayan121
> i try to avoid copying anything than 2 pointers...
swapping pointers is easy; swap pointers to arrays just like you swap any other pointers.
#include <stdio.h>

void swap( int rows, int cols,...
Forum: C++ May 14th, 2008
Replies: 6
Solved: Threads!
Views: 862
Posted By vijayan121
> maybe the book Java Concurrency in Practice addresses this thing
no, it doesn't. it is a good book on concurrency issues in general, but discusses only java.

> where do you stand vijayan121...
Forum: C++ May 13th, 2008
Replies: 6
Solved: Threads!
Views: 862
Posted By vijayan121
> is there any way to use threads in c++

the ISO standards committee (c++09) has voted voted in a number of concurrency extensions into the working draft (memory model, atomics library, basic...
Forum: C++ May 12th, 2008
Replies: 8
Views: 808
Posted By vijayan121
for(it = aMap.begin(); it != aMap.end(); it++){
//some processing
if(//some condition){
//some processing
aMap.erase(key);
// this is undefined behaviour
// the iterator is...
Forum: C++ May 9th, 2008
Replies: 3
Solved: string sort
Views: 1,792
Posted By vijayan121
sort before inserting the string into the multimap?
void fill_mmap( std::multimap< std::string, int >& mmap,
std::ifstream& file )
{
std::string line ;
for( int line_num = 1...
Forum: C++ May 7th, 2008
Replies: 5
Views: 442
Posted By vijayan121
> Do you know how you would go about finding the length of an array?
the array 'decays' into to a pointer when you pass it to a function.
also pass the size of the array (as a second parameter) to...
Forum: C++ May 7th, 2008
Replies: 5
Views: 2,028
Posted By vijayan121
> Is there anything that 'wraps' pipes?
i do not know of any, but it is very easy to roll out one of our own. eg.
#include <stdio.h>
#include <boost/iostreams/device/file_descriptor.hpp>
#include...
Forum: C++ May 7th, 2008
Replies: 5
Views: 442
Posted By vijayan121
void clearCharArray( char arrayToClear[] )
{
int arrayLength = 0;

// Get the length of the array passed
// this will not give you the length of the array passed
arrayLength = sizeof(...
Forum: C++ Apr 28th, 2008
Replies: 5
Views: 1,315
Posted By vijayan121
#include <algorithm>

class LakeDataClass
{
public:
char DTG[13];
float DepthOfMeasurements;
char WaveDirectionStrength[5];
char Weather[9];
float DissolvedOxygen;
Forum: C++ Apr 27th, 2008
Replies: 5
Views: 1,315
Posted By vijayan121
dragon: > You might also be able to do this with templates
yes, if there are a lot of members, templates would provide a generic mechanism.
didn't post this earlier because i didn't want to scare...
Forum: C++ Apr 27th, 2008
Replies: 9
Views: 3,485
Posted By vijayan121
> I find it interesting that the resolution implied by CLOCKS_PER_SEC is 1/1000000 second,
> but my actual results show 1/100 second.
how typical of linsux. appearances are more important than...
Forum: C++ Apr 26th, 2008
Replies: 9
Views: 3,485
Posted By vijayan121
the C library clock() does not give the wall clock:

just sleeping or waiting for input will work for time() (which gives the wall time), not for clock(); no processor time is used by the process...
Forum: C++ Apr 25th, 2008
Replies: 5
Views: 1,315
Posted By vijayan121
let's say you have a struct/class of this kind:
struct A
{
int number ;
double value ;
char name[30] ;
};
and you want to sort an array of As on the member value.
first, write a...
Forum: C++ Apr 23rd, 2008
Replies: 4
Views: 1,849
Posted By vijayan121
do not pass the address of a local variable (with automatic storage duration) to a thread function; it may not be around by the time the thread executes.
// ...
char* input_sentence = new char[32];...
Forum: C++ Apr 23rd, 2008
Replies: 2
Views: 1,226
Posted By vijayan121
ideally, do not use the (now deprecated) functionality in namespace __gnu_cxx. they have been superceded by tr1 in c++0x.
use -std=c++0x (gcc 4.3) , std::tr1 (gcc4.2) or boost::tr1 (earlier...
Showing results 1 to 40 of 295

 


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

©2003 - 2009 DaniWeb® LLC