pointers: he likes sharks,frogs and other exotic animals. He also like dragons. He recently broke his phone which he used mostly because of the camera in it.
(A) digital camera for birthday (october) , books with facts about exotic animals for anniversary (november), shirt with dragon for xmas (dec)
(B)digital camera (october), wristwatch (november), books about exotic animals (december)
(C) digital camera (october), wristwatch (december), shirt with dragon (november)
JUST USE A. B or C and add a comment if you want
thanks
(POLL) Presents for my man..HELP ME, CHOOSE A, B or C?
I think the "B" is really good!!!!!.
Bye!.
JULIA.
=)
Reply:I think C
Reply:C - consider getting a gift card to a bookstore, instead of choosing the books for him.
Reply:A
Reply:A, B and C... for sure he will be happy...
Reply:B) Because he needs a camera and likes exotic animals.
Reply:B
Reply:I think A...
salary survey
Sunday, August 2, 2009
When are pointers pass by value and when are they pass by reference in a c++ function?
Passing by value and passing by reference are the same for pointers as for ordinary variables.
When passing a pointer by value, you're actually passing the address that the pointer points to.
When passing a pointer by reference, you're passing the address of the pointer, which itself is the address of some other item.
Passing by reference allows you to change the location that the pointer points to whereas by value just lets you use that address - it'll have no effect on the pointer when the function returns.
When are pointers pass by value and when are they pass by reference in a c++ function?
Pass by value when you want to retain the original value regardless of changes to the value inside the function.
Pass by reference when you require the original value to be changed.
When passing a pointer by value, you're actually passing the address that the pointer points to.
When passing a pointer by reference, you're passing the address of the pointer, which itself is the address of some other item.
Passing by reference allows you to change the location that the pointer points to whereas by value just lets you use that address - it'll have no effect on the pointer when the function returns.
When are pointers pass by value and when are they pass by reference in a c++ function?
Pass by value when you want to retain the original value regardless of changes to the value inside the function.
Pass by reference when you require the original value to be changed.
(POLL) Presents for my man..HELP ME, CHOOSE A, B or C?
pointers: he likes sharks,frogs and other exotic animals. He also like dragons. He recently broke his phone which he used mostly because of the camera in it.
(A) digital camera for birthday (october) , books with facts about exotic animals for anniversary (november), shirt with dragon for xmas (dec)
(B)digital camera (october), wristwatch (november), books about exotic animals (december)
(C) digital camera (october), wristwatch (december), shirt with dragon (november)
JUST USE A. B or C and add a comment if you want
thanks
(POLL) Presents for my man..HELP ME, CHOOSE A, B or C?
A....and I sure hope he is worth all this ,,I assume he is...Good luck
Reply:C is a good choice. My birthday is in November and I like Wolves..............Hint, hint......LOL
Reply:A and i wish i had a girl like you lol
Reply:A
Reply:get him a vibrating thing a-ma-jig at sharper image
Reply:I like B
Reply:c
Reply:i would chose b... but I'm a bit confused u want to get 3 gifts. the digital camera ids really nice because the pictures will create many memories.
the wrist watch is nice too, its always nice to know the time and it helps to be punctual.
i would chose a book over a shirt because i believe the book will get more use and be around longer
Reply:C
(A) digital camera for birthday (october) , books with facts about exotic animals for anniversary (november), shirt with dragon for xmas (dec)
(B)digital camera (october), wristwatch (november), books about exotic animals (december)
(C) digital camera (october), wristwatch (december), shirt with dragon (november)
JUST USE A. B or C and add a comment if you want
thanks
(POLL) Presents for my man..HELP ME, CHOOSE A, B or C?
A....and I sure hope he is worth all this ,,I assume he is...Good luck
Reply:C is a good choice. My birthday is in November and I like Wolves..............Hint, hint......LOL
Reply:A and i wish i had a girl like you lol
Reply:A
Reply:get him a vibrating thing a-ma-jig at sharper image
Reply:I like B
Reply:c
Reply:i would chose b... but I'm a bit confused u want to get 3 gifts. the digital camera ids really nice because the pictures will create many memories.
the wrist watch is nice too, its always nice to know the time and it helps to be punctual.
i would chose a book over a shirt because i believe the book will get more use and be around longer
Reply:C
Where can i find an online free massachusetts P&C practice insurance exam?
Im looking to take a practice exam for massachusetts Personal lines %26amp; P%26amp;C can someone please tell me where to find one? Or if you have taken these exams any pointers?
Where can i find an online free massachusetts P%26amp;C practice insurance exam?
please search www.google.com
Where can i find an online free massachusetts P%26amp;C practice insurance exam?
please search www.google.com
Can someone help debug this part of my C Basic program?
//Alphabetization of Multi-Dim string//
void bubblesort(char *R[], int a); //function declaration//
char *restname[20][30]; //Variable in main//
bubblesort(restname[30], 20);//Function bubblesort in main//
void bubblesort(char *R[], int a)//function bubble sort//
{ int i, j; char *hold;
for(i= 0; i %26lt; a; i++)
{ for(j=0; j%26lt;a-1; j++)
{ if(R[j] %26lt; R[j+1])
{ hold = R[j];
R[j] = R[j+1];
R[j+1] = hold;}
}
}
for(i=0; i%26lt;a; i++)
{ printf("%s", R[i]);
printf("\n"); }
} //end function//
This is for my CSE 1320 programming class
I cant figure out how to get the NEW restname multi-dimensional string to print in alphabetical order! I also cannot use any C,Basic built-in sort functions for this project AND i HAVE to use the sort function using pointers
Can somebody PLEASE help me?
If more info is needed, let me know... but i cant post the program in its entirity due to its length exceeding this text box's character limit
Thanks
Can someone help debug this part of my C Basic program?
I get the point. Your program is in descending order. So, you wish to arrange the characters alphabetically in descending order. The program will give you a syntax error because you cannot have a pointer that can also act as an array. Within the arguments of the bubblesort, there is a declared variable "*R[]" of character type. You can have "*R" or "R[]" but not "*R[]".
Bubble sort deals its elements individually, so I think it's better to use "%c" than "%s"
The main part that confuses me much is that you declared a 2-dimensional array to be passed in the arguments of bubblesort but in the bubble sort arguments you placed a 1-dimensional array and its size. If that is what is passed to the arguments then the entire program is logically erroneous because it only applies to a one-dimensional array.
surveys
void bubblesort(char *R[], int a); //function declaration//
char *restname[20][30]; //Variable in main//
bubblesort(restname[30], 20);//Function bubblesort in main//
void bubblesort(char *R[], int a)//function bubble sort//
{ int i, j; char *hold;
for(i= 0; i %26lt; a; i++)
{ for(j=0; j%26lt;a-1; j++)
{ if(R[j] %26lt; R[j+1])
{ hold = R[j];
R[j] = R[j+1];
R[j+1] = hold;}
}
}
for(i=0; i%26lt;a; i++)
{ printf("%s", R[i]);
printf("\n"); }
} //end function//
This is for my CSE 1320 programming class
I cant figure out how to get the NEW restname multi-dimensional string to print in alphabetical order! I also cannot use any C,Basic built-in sort functions for this project AND i HAVE to use the sort function using pointers
Can somebody PLEASE help me?
If more info is needed, let me know... but i cant post the program in its entirity due to its length exceeding this text box's character limit
Thanks
Can someone help debug this part of my C Basic program?
I get the point. Your program is in descending order. So, you wish to arrange the characters alphabetically in descending order. The program will give you a syntax error because you cannot have a pointer that can also act as an array. Within the arguments of the bubblesort, there is a declared variable "*R[]" of character type. You can have "*R" or "R[]" but not "*R[]".
Bubble sort deals its elements individually, so I think it's better to use "%c" than "%s"
The main part that confuses me much is that you declared a 2-dimensional array to be passed in the arguments of bubblesort but in the bubble sort arguments you placed a 1-dimensional array and its size. If that is what is passed to the arguments then the entire program is logically erroneous because it only applies to a one-dimensional array.
surveys
Friday, July 31, 2009
How to use new operater in a C++ class?
Does anyone know how to use and implement the new operator in a class? I have a test on this in 8 hours and I barely understand classes. I understand pointers a little better. Can someone give me a quick simple demo? Basically my test is going to give me a class and I will have to insert a new operator line to get it to work, it will most likely deal with arrays. I need to pass this test to pass the class, I'm desperate. I use visual C++ 2008, just anything that can compile.
How to use new operater in a C++ class?
The 'new' operator is utilized when you want to declare a dynamic variable. This variable does not have a name; it can only be accessed through the pointer that you declared it with. For example, in your 'main' function you might write:
int *p, *q; // Declare p and q are each int pointers.
p = new int; // Declare that p points to an unnamed variable of type int.
q = new int[10]; // Declare that q points to an unnamed array of 10 variables of type int.
Before the dynamic variable goes out of scope, you need to write:
delete p; // Free the memory for the unnamed int pointed to by p.
delete [ ] q; // Free the memory for the unnamed int array pointed to by q.
Suppose you have already declared and defined a Distance class. In your 'main' function you might write:
Distance *d1, *d2; // Declare d1 and d2 are each Distance pointers.
d1 = new Distance; // Declare that d1 points to an unnamed object of type Distance.
d2 = new Distance[10]; // Declare that d2 points to an unnamed array of 10 objects of type Distance.
Suppose that 'getDistance()' is one of the public member functions that you declared in your definition of the Distance class. To CALL that function (from your 'main' function) for each successive Distance object in the array, you might write:
for (int i=0; i%26lt;10; i++)
d2[i].getDistance();
Before the dynamic variable goes out of scope, you need to write:
delete d1; // Free the memory for the unnamed Distance object pointed to by d1.
delete [ ] d2; // Free the memory for the unnamed Distance array pointed to by d2.
A separate issue: You can declare dynamic variables inside a class. Suppose your Distance class has only pointers as private data members:
class Distance
{
private:
int *ft; // pointer to int
float *in; // pointer to float
public:
Distance(); // constructor
// Declare your other class member functions here:
};
// Define your class constructor:
Distance::Distance()
{ feet = new int; // Declare an unnamed int pointed to by the pointer 'feet'.
*feet = 0; // Initialize variable pointed to by 'feet' to value of zero.
inches = new float; // Declare an unnamed float pointed to by the pointer 'inches'.
*inch = 0.0; // Initialize variable pointed to by 'inches' to value of zero.
}
Or instead, you could declare a Distance class that has a constructor in which the pointers declare an array of 5 ints pointed to by 'feet' and an array of 5 floats pointed to by 'inches'. In that case you would initialize each of the array members using a for loop.
Distance::Distance()
{
feet = new int[5];
inches = new float[5];
for (int i=0; i%26lt;5; i++)
{ feet[i] = 0; inches[i] = 0.0; }
}
How to use new operater in a C++ class?
The 'new' operator is utilized when you want to declare a dynamic variable. This variable does not have a name; it can only be accessed through the pointer that you declared it with. For example, in your 'main' function you might write:
int *p, *q; // Declare p and q are each int pointers.
p = new int; // Declare that p points to an unnamed variable of type int.
q = new int[10]; // Declare that q points to an unnamed array of 10 variables of type int.
Before the dynamic variable goes out of scope, you need to write:
delete p; // Free the memory for the unnamed int pointed to by p.
delete [ ] q; // Free the memory for the unnamed int array pointed to by q.
Suppose you have already declared and defined a Distance class. In your 'main' function you might write:
Distance *d1, *d2; // Declare d1 and d2 are each Distance pointers.
d1 = new Distance; // Declare that d1 points to an unnamed object of type Distance.
d2 = new Distance[10]; // Declare that d2 points to an unnamed array of 10 objects of type Distance.
Suppose that 'getDistance()' is one of the public member functions that you declared in your definition of the Distance class. To CALL that function (from your 'main' function) for each successive Distance object in the array, you might write:
for (int i=0; i%26lt;10; i++)
d2[i].getDistance();
Before the dynamic variable goes out of scope, you need to write:
delete d1; // Free the memory for the unnamed Distance object pointed to by d1.
delete [ ] d2; // Free the memory for the unnamed Distance array pointed to by d2.
A separate issue: You can declare dynamic variables inside a class. Suppose your Distance class has only pointers as private data members:
class Distance
{
private:
int *ft; // pointer to int
float *in; // pointer to float
public:
Distance(); // constructor
// Declare your other class member functions here:
};
// Define your class constructor:
Distance::Distance()
{ feet = new int; // Declare an unnamed int pointed to by the pointer 'feet'.
*feet = 0; // Initialize variable pointed to by 'feet' to value of zero.
inches = new float; // Declare an unnamed float pointed to by the pointer 'inches'.
*inch = 0.0; // Initialize variable pointed to by 'inches' to value of zero.
}
Or instead, you could declare a Distance class that has a constructor in which the pointers declare an array of 5 ints pointed to by 'feet' and an array of 5 floats pointed to by 'inches'. In that case you would initialize each of the array members using a for loop.
Distance::Distance()
{
feet = new int[5];
inches = new float[5];
for (int i=0; i%26lt;5; i++)
{ feet[i] = 0; inches[i] = 0.0; }
}
What is the point of having a private class for C++? What is also the point in having a public class?
what is the point of having a private class for C++? What is also the point in having a public class? Why do people use a public and private class, also aren't pointers involved somewhere in there?
Subscribe to:
Posts (Atom)