bhoot_jb 47 Junior Poster in Training

hey friends i am working with a program of "stack of stack".....and i thought to work it out using inheritance....but i m stuck in it...
i thought to inherit both the stack - the parent stack and a stack element....from a single base class..
i mean i am in dilemma of how to use inheritance...the basic functions of a stack wud be...push, pop, view, isempty...etc.
for push d functions wud differ as push(stack) in parent stack and push(int) in mini stack....
same for oders...
so any suggestions...?? or shud i drop dis idea??? :|

bhoot_jb 47 Junior Poster in Training

hey friends...i am a beginner in VB applications..and while linking databases with my projects i have come across these terms : COM, OLE, OLE DB, OCX, ActiveX
Though i vaguely know about them i often get confused between them...i guess because of their close relationships..so please anyone clearly explain what they are and also the differences between them...
Also please explain their relations with DAO, RDO and ADO...i think OLE is related to DAO..and OLE DB to RDO....but not sure...
can anyone help me??

bhoot_jb 47 Junior Poster in Training

hey friends...i am a beginner in VB applications..and while linking databases with my projects i have come across these terms : COM, OLE, OLE DB, OCX, ActiveX
Though i vaguely know about them i often get confused between them...i guess because of their close relationships..so please anyone clearly explain what they are and also the differences between them... :)
Also please explain their relations with DAO, RDO and ADO...i think OLE is related to DAO..and OLE DB to RDO....but not sure... :( :P :)
can anyone help me??

bhoot_jb 47 Junior Poster in Training

hey yaa..i got it...i thnik the homepage was under some sort of maintenance...or whatever it was...but later i was able to access the homepage..i downloaded it from there... :)

bhoot_jb 47 Junior Poster in Training

now what's the difference between only "bloodshed C++" and "bloodshed C++ IDE"??
u meant that the former is only a compiler and the latter an IDE??

and yaa..i could not download from the link given by you...because it ultimately tried to access bloodshed's parent site www.bloodshed.net which is inaccessible for a dont-know reason :P :|

bhoot_jb 47 Junior Poster in Training

can anyone tell from where i can download the latest bloodshed dev C++ IDE...
my problem is i am not able to access the www.bloodshed.net...
:(
so is there any other link to download it??

bhoot_jb 47 Junior Poster in Training

code::blocks uses MinGW, which is GCC underneath.
And gcc is a very good compiler, one of the best in the price range.

The -ansi option is good for making sure you actually learn about standard C++, and not a bunch of compiler specific extensions.

yaaa..okkk..got it...code::blocks is an IDE..using GCC compiler...i mean underneath GCC..
am i right?? :)
okk...bro...thnx for this...i am thinking to try this code::blocks...and then might move towards visual C++ ... :)

Salem commented: You've got it! +16
bhoot_jb 47 Junior Poster in Training

http://www.compilers.net/
http://www.thefreecountry.com/compilers/cpp.shtml

> Also which one is the best compiler?
A topic of endless debate :)

lolz...i know that...but i wanted the opinions... ;) :)
anyways..is it fine to use CodeBlocks (coz i have it :) )... ??
i have written some codes on it..
its something related to GCC.. :|

bhoot_jb 47 Junior Poster in Training

hey friends i am in dilemma of which compiler to use..
i have been working on windows OS.
also the C++ concepts that we are taught in our college are practically taught on Borland Turbo C++ compiler (dunno how aged it it :P) :(
i mean we people write the codes in Turbo C++ compiler which i think has been discarded since ages.
Now just hell with the college...i want to know whether to stick to this buggy compiler or to start working on other compilers like GNU's GCC ?
Also which one is the best compiler?
And what has VC++ to do with this? i mean it has GUI interface..anything else?
thanx for any help you people provide :)

bhoot_jb 47 Junior Poster in Training

hey friends using scanf of C ...one can set the input width...something like this..

scanf ("%3d", i);

then whats d thing that i can use to do the same in C++ using cin... ???

bhoot_jb 47 Junior Poster in Training

heyy friends ...i am facing a umm...weird problem...
the contrast setting of my monitor often gets displayed on my screen automaticaly...on its own...
nd it always sets itself to 100...and no sooner i decrease it than it sets itself to 100 again..
it has become an irritation now..
and to make it disappear i often need to restart my monitor...
so what do you people think the problem is???
:(

bhoot_jb 47 Junior Poster in Training

try to delete or open that or why don't try to delete it via command prompt.... or worst why don't you reformat that

well...actualy i want that data on my pc...
so i copied it...and after using it i want to delete it...
thats where i am facing the prob...
i cant delete it..coz its read-only..
even if i change the attribute...it reverts to read-only..
i think the virus (or whatever) was on my pc itself.. :(

bhoot_jb 47 Junior Poster in Training

yaa...i have downloaded the compiler...thanxx for the help friends... :)

bhoot_jb 47 Junior Poster in Training

hey friends..my pc is facing a problem of read-only attribute files and folders...
i accessed a pen drive and all the files and folders of that pen drive became read-only (which were not read-only)....
and after copying some of the folders from the pendrive...i am not able to delete them from my pc due to the read-only attribute...so which virus am i facing?? and what is the solution to that??? :(

bhoot_jb 47 Junior Poster in Training

http://gcc.gnu.org/ is the official site for the gcc compiler. Latest version was released in March this year and is version 4.3.0. Note that it is actually a standard compiler that is usually included in a standard install of Linux or the Mac OS as well. So you probably only need to download it if you are running windows.

hey ya buddy...i am running windows XP...so i need to download it.. :(
:)
and i have also visited that site...but couldnt find the actual link from where to download.. :|

bhoot_jb 47 Junior Poster in Training

right now i am working with Turbo Borland C++ compiler...however now i want to have a try on GCC compiler too...
so where would i get it??
can anybody provide a reliable link to a GCC compiler??? :)

bhoot_jb 47 Junior Poster in Training

ohkkk ... :)
thnxx... :)

bhoot_jb 47 Junior Poster in Training

>>then what is the difference between both styles ??
The first is most definitely an array. The second may or may may not be an array because it could also be a pointer to a single int object. function() must be made smart enough to know whether *p is a pointer to an object or an array. In both versions of the function it must also know how many elements are in the array.

bro..
but i am passing an array to both the functions...
i just want to know the difference at that time... :|

bhoot_jb 47 Junior Poster in Training

i want to clear a doubt...
please check out the following codes..

int function (int p[])
{
  //sm code
}

another style is :

int function (int *p)
{
  // sm code
}

here i am passing an array to both the functions...and one receives it through p[] and another through *p....
then what is the difference between both styles ??
or just that the former uses subscript and the latter dereferences the pointer to access the values... ??
please clear out my doubt...

bhoot_jb 47 Junior Poster in Training

IMO -- In My Opinion

ohkkk :)
thanksss.. :)

bhoot_jb 47 Junior Poster in Training

yaaa...i thought the same way...i am able to use the 2-d array style to access the elements in the 2nd style...hmm..okk..thankss.. :)
and what is this IMO??? :|

bhoot_jb 47 Junior Poster in Training

heyy sorry moderators...i actually forgot to put the code tags... :(
but thanks to ur efficient system... :)

bhoot_jb 47 Junior Poster in Training

please check out the following two code segments and suggest which one is more efficient and worthy to use...

The segments are actually constructors used to allocate a memory block for a matrix..


segment - 1 :

class matrix
{
  private :
    int rows, columns;
    int *element;

  public :
  // constructors
    matrix();
    matrix (int , int);

  // member functions
};

matrix :: matrix (int r, int c)
{
 rows = r;
 cols = c;
 element = new int [r * c];
}

segment - 2 :

class matrix
{
  private :
    int rows, columns;
    int **element;

  public :
  // constructors
    matrix();
    matrix (int , int);

  // member functions
};

matrix :: matrix (int r, int c)
{
 rows = r;
 cols = c;
 element = new int* [rows];
 int i = 0;
 while (i < rows)
 {
    *(element+i) = new int [cols];
    ++i;
 }
}

well....i think 1st one is more efficient... ;) ....and obviously more simple...
please give your views... :)

bhoot_jb 47 Junior Poster in Training

hahaha...ohkkk..i got it friendsss... :)
was just kidding...
but thank you people for clearing my doubt...
i would surely come back with more doubts... :)

bhoot_jb 47 Junior Poster in Training

so u ppl mean i shouldnt be using this type of weird and idiotic code...rite??
:D
okkk...thanx for help anyways... :)

bhoot_jb 47 Junior Poster in Training

well...i duno what u r saying...
none of my program crashed...
instead both of them worked well and fine..
infact in the 2nd question it printed the values (i guess garbage) for *p and p...
so what say now??

bhoot_jb 47 Junior Poster in Training

i have two questions right now in my mind :

question - 1 :

please have a look at this code :

void function (int recd)
{
   printf ("%d", recd);
}
void main()
{
  int p=10;
  function(p);
}

here...when p is passed to function, the thing that actually takes place is :
a new variable recd is created and value of p is copied to recd (i mean a copy of p is created...consuming another 2 bytes)...

now please check the following code :

void function (int *recd)
{
   printf ("%d", *recd);
}
void main()
{
  int *p;
  *p=10;
  function(p);
}

does the same thing happen here?? i mean here too.. new pointer variable recd is created and value (an address) stored in pointer p is copied to recd???

void function (int *recd)
{
  printf ("%d", *recd);
}

void main()
{
   int p=10;
   function(&p);
}

and here too, does the same thing happens???
please throw some light on it... :)


question - 2:

void main()
{
   int **p;
   **p = 10;   
}

in the above code, where the hell is 10 stored???
what exactly happen in above code??
my guess is : its stored in *p...
i mean **p has a garbage which is taken as *p...and *p has a garbage which is taken as the address of 10....is this right or a garbage?? :P :)

bhoot_jb 47 Junior Poster in Training

k....got your point ... :)

bhoot_jb 47 Junior Poster in Training

okkk...but i have one doubt...if i receive through a pointer i guess it wont create a copy...
and 2nd thing is i if i pass a pointer then i will have to receive it by a double pointer...else the change wont take place in the original pointer variable...
pls throw some light on this..

bhoot_jb 47 Junior Poster in Training

i am working with a matrix manipulation program...consists of a matrix class and its member functions..
i have also overloaded << and >>...so dat dey can read and print d whole matrix at one statement..
the code of these overloaded operators is something like this..

// for >> (cin) :
istream& operator >> (istream &read, matrix &mat)
{
	for (int i = 0; i < mat.rows * mat.columns; ++i)
		read >> *(mat.element+i);
	return read;
}

// for << (cout) : 
ostream& operator << (ostream &print, matrix &mat)
{
	for (int i = 0; i < mat.rows; ++i)
	{
		for (int j = 0; j < mat.columns; ++j)
		{
			print << *mat.element << "  ";
			++mat.element;
		}
		print << endl;
	}
	mat.element -= mat.rows * mat.columns;
	return print;
}

here i have received the variable matrix1 by reference...in main() i have used a variable matrix1 which is passed as follows :
matrix matrix1;
cin >> matrix1;

now...my question is :
wat if i want to pass a pointer variable which should be received by a reference...smthing like this...

main()
{
   matrix *matrix2;
   cin >> matrix2; //i aint sure that this statement is right...it may be cin >> *matrix2...
}

the overloaded function for pointer thing is coded as follows :

for >> :
istream& operator >> (istream &read, matrix *&mat)
{
	for (int i = 0; i < mat->rows * mat->columns; ++i)
		read >> *(mat->element+i);
	return read;
}

// for << : …
bhoot_jb 47 Junior Poster in Training

heyyy yaaa!! i got it!!
that means i do have that element ...
but i have lost the pointer.... :)
ohkk!!
so it means that the only way is to return a copy of the variable... :)
but if there is any other efficient way to return "result" then suggestions are most welcome... :)

bhoot_jb 47 Junior Poster in Training

hey..but then what about the allocation of memory that i have done??
i have actually allocated memory to the "result" using new operator..while declaring it using copy constructor :

matrix result (rows, columns);

then should not the variable retain its value??
or due to the local scope...new has no effect ??

bhoot_jb 47 Junior Poster in Training

>That won't work. Local variables are destroyed when execution leaves their containing scope. What you should be doing is returning a copy of the local variable.

heyyy...yaaa..i understood my stupidity....that is a local variable i am returning.. :P
actually the pointers are useful when a variable passed from the main() to a function is returned to the main().... :)
anyways...thanks for that...
:)

bhoot_jb 47 Junior Poster in Training

i hav coded a matrix class and its member functions (many of them are overloaded ones)...now in a function..for eg. function of matrix addition.. after the addition i want to return the local object "result" through a pointer (and not call by value)..however i aint getting d values of the result in main()...instead i am getting garbage values when i print it...

here is my code :

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

// general function declarations

void list (int *choice);


// class declaration
[B]class matrix
{
	private :
		int rows;
		int columns;
		int * element;

	public :
		matrix();
		matrix (int, int);
		void setdata (int, int, int *);
		void showptrdata();
		matrix* operator+(matrix &);

	friend istream& operator >> (istream &, matrix &);
	friend ostream& operator << (ostream &, matrix &);
	// function overloading -- for printing a pointer object
        friend ostream& operator << (ostream &, matrix *&);

};[/B]


matrix :: matrix ()
{
	rows = 0;
	columns = 0;
	*element = 0;
}

matrix :: matrix (int r ,int c)
{
	rows = r;
	columns = c;
	element = new int [rows * columns];
}

istream& operator >> (istream &read, matrix &mat)
{
	for (int i = 0; i < mat.rows * mat.columns; ++i)
		read >> *(mat.element+i);
	return read;
}

[B]ostream& operator << (ostream &print, matrix &mat)
{
	for (int i = 0; i < mat.rows; ++i)
	{
		for (int j = 0; j < mat.columns; ++j)
		{
			print << *mat.element << "  ";
			++mat.element;
		} …
bhoot_jb 47 Junior Poster in Training

ohkkk narue...
sorry for that...actually i am used to type english in such a rubbish way :(...anyways..i wont do so again... :)

bhoot_jb 47 Junior Poster in Training

>>No, it's a big security risk, and the system function is painfully slow.

thnxx...i wont ever use dis thing... :)

>>This is your most portable option, but you can't tell how many newlines to print, and the cursor will be at the bottom of the screen rather than the top as it would be in a true screen clear.

u r ritee...tho it clears d screen, d cursor will be at the bottom which is undesirable...actualy dat issue went out of my mind while i was replying d post.. :|

>>Here's a solution that's portable across Windows, but it won't work on other operating systems without emulation:

well...thnxx for d solution...but d question of includin another file still remains...(windows.h here)... :)
i had actualy thot of accomplishin d task using only iostream.h (which is d only file used by me other dan conio.h in my program)....
neways....i wud continue wid clrscr() for d time being.... :)
because i dnt need to run d code using a compiler except Borland's... :)

bhoot_jb 47 Junior Poster in Training

well...i told i m a beginner in C++...so dnt kno much about d stuffs... :) so naturaly i wud prefer the most common ways...
neways...thnx for d help...rite now i wud better go on wid clrscr().... :)

bhoot_jb 47 Junior Poster in Training

To my knowledge, there is no standard way to clear the screen in C/C++, because that's not the way the console was designed. If you want to clear the screen then you have to do it using some non-standard way. You can write your own function to do this or use a third party function like clrscr(). I'll be happy to learn along side you if I'm wrong.

heyy yaa...i encountered the same answer as given by you in different sites...so i agree with you...but then i wud like u to tell me if its good to use system('cls') (or watever it is..) ???
is it risky ??
or shall i create a loop of '\n' so that it will jst bring a new screen in front of me...???

which one is a better option ?? yaa...any other more feasible option is welcome. ... :)

bhoot_jb 47 Junior Poster in Training

heyy friends..
i m a beginner in C++ and am currently workin wid a program..

just for clrscr(), i have to include the whole conio.h file in my program inorder to clear the screen..
so is there any alternative to clrscr()??
please throw some light on this topic.. :)