I wonder if it is a good practice to have a member template function inside a non-template class in c++? Why?
I'm trying to do something like this
in classA.h:
classA
{
public:
member_func1();
member_func2();
};
in classA.cpp:
template <class T> share_func();
classA::member_func1()
{
call share_func();
}
classA::mem...
location pick(void){ // generates a random location
location get;
get.x = rand() % FIELD_SIZE + 1;
int forY = rand() % FIELD_SIZE +1;
switch(forY){
case 1:
get.y = 'a';
break;
case 2:
get.y = 'b';
break;
case 3:
get.y = 'c';
break;
case 4:
...
i'm having an issue understanding why the following works:
void doubleAddr(double* source, double** dest)
{
*dest = source;
}
i get a pointer to a double and want to change the double that dest points to:
//usage:
int main()
{
double* num;
double* dest;
doubleAddr(num, &dest);
return 0;
}
thanks in advanc...
Hi all,
I am looking for a function that will tell me, for a list of packages, which of them is up to date and which is not (I need it so to trace back an R crash).
Thanks,
Tal
...
hello friends my question is i am having two function f1 and f2 and if i want to execute function f2 after execution of f1 how is it possible?
...
I have a program I am trying to debug, but Dynamic C apparently treats strings differently than normal C does (well, character arrays, anyway). I have a function that I made to make an 8 character long (well, 10 to include the \0 ) string of 0s and 1s to show me the contents of an 8-bit char variable. (IE, I give it the number 13, it r...
Is this the right way to return an object from a function?
Car getCar(string model, int year) {
Car c(model, year);
return c;
}
void displayCar(Car &car) {
cout << car.getModel() << ", " << car.getYear() << endl;
}
displayCar(getCar("Honda", 1999));
I'm getting an error, "taking address of temporary". Should I use this way:...
Stupid question, this code:
<?php
$variable = system("cat /home/maxor/test.txt");
echo $variable;
?>
with file test.txt:
blah
prints:
blah
blah
What can I do with system() function to not print nothing so I get 1 "blah"???
...
Hi, I'm trying to use this formula in JAVA : (-ln(1-L))/L
I'm not sure how to use ln in java. thanks in advance
...
I have a vector called players and a class called Player. And what I'm trying to do is to write:
players.push_back(Player(name, Weapon(bullets)));
So I want to be able to create players in a loop. But I see an error message says "no matching function for call Player::Player..."
Then I've changed that to:
Weapon w(bullets);
Player p(...
on master page i put this code to load page in same master page and then run jqeury function
This is my Master Page code
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html x...
Here is my code that fails:
bool Table::win(const Card &card) {
for (int i = 0; i < cards.size(); i++)
if (card.getRank() == cards[i].getRank()) return true;
return false;
}
Error message is: passing 'const Card' as 'this' argument of 'int Card::getRank()' discards qualifiers.
When I get a copy of the card and change the...
I am kind of new to C (I have prior Java, C#, and some C++ experience). In C, is it necessary to declare a function prototype or can the code compile without it? Is it good programming practice to do so? Or does it just depend on the compiler? (I am running Ubuntu 9.10 and using the GNU C Compiler, or gcc, under the Code::Blocks IDE)
...
I was working on my advanced calculus homework today and we're doing some iteration methods along the lines of newton's method to find solutions to things like x^2=2. It got me thinking that I could write a function that would take two function pointers, one to the function itself and one to the derivative and automate the process. This ...
Say I have class A and class B. B inherits from class A, and implements a few virtual functions. The only problem is that B is defined in a .dll. Right now, I have a function that returns an instance of class A, but it retrieves that from a static function in the .dll that returns an instance of class B. My plan is to call the created ob...
I want to get function name of the exception thrown from dll in asp.net.
...
I have a text file named num.txt who's only contents is the line 123. Then I have the following:
void alt_reader(ifstream &file, char* line){
file.read(line, 3);
cout << "First Time: " << line << endl;
}
int main() {
ifstream inFile;
int num;
inFile.open("num.txt");
alt_reader(inFile, (char*)&num);
cout << "...
Is there any considerations to determine which is better practice for creating an object with private members?
var object = new function () {
var private = "private variable";
return {
method : function () {
..dosomething with private;
}
}
}
VS
var object = function () {
...
}();
Basically what ...
Hi, I see C books that use the same variable names in the function definition, calling function and declaration. Others use the same variable names in the calling function and in the declaration/prototype but a different one in the definition as in:
void blabla(int something); //prototype
blabla(something) // calling function inside m...
Hello, I try to call a function which passed as function pointer with no argument, but I can't make it work.
void *disconnectFunc;
void D::setDisconnectFunc(void (*func)){
disconnectFunc = func;
}
void D::disconnected(){
*disconnectFunc;
connected = false;
}
...