You are not logged in.
thanks!
Btw, i had two queestions. Can you make a pointer to a method of class A point to a method of class B where B is a subclass of A? It failed to work when I tried it but I was wondering if maybe you could do it with casting.
Also, can you return a pointer to a function from a function? that is, can a functions return type be a pointer to a function?
this is weird...
I clicked on help/about dev-C++ in the IDE, here's what it says at the top:
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.the license is apparently about 17 years old... but I seriously doubt they would put a 1991 compiler on a website still in use today. (or at least as of august 2007)
It may be just an outdated compiler, but even if it was, it still understands the declaration:
int (Dog*p)(long, double);
it just doesn't let me do anything with p after that. At least i haven't found a way yet.
anyway, Ricky. This isn't a major issue, first because i normally use my borland compiler, and second because i don't really intend to use pointers to functions anyway as it seems to be a discouraged technique. The point is that I know the correct way to do it when I need it, and to recognize when other people use it.
SO! which is the correct method? To use p = dog::bark; or p = &dog::bark; ?
they don't have C++ compilers on my schools computers (my school is java biased!)
here's where i download it
http://www.bloodshed.net/devcpp.html
mm... i think you read my post too fast, Ricky! I said I tried that and it didn't work.
But at the moment I'm about to leave for school and haven't much time so.. perhaps I read YOUR post too fast. I'll look more carefully later.
my latest topic: Pointers to functions!
I'm having some compiler/book disagreement when using pointers to member functions.
consider the following program
#include <iostream>
class Dog
{
public:
Dog() {}
~Dog() {}
// method to be pointed to
int bark(long l, double d) { std::cout << "bark " << (l*d) << " times\n"; return 0; }
};
int main()
{
// declare pointer to any dog method that takes a long and a double and returns an int
int (Dog::*p)(long, double);
p = Dog::bark; // bad???
Dog pokey;
(pokey.*p)(2,4);
return 0;
}according to my book, the statement p = Dog::bark; is how you make p point to that method. On my compiler at home (borland) it compiles and works fine. But today I was using a compiler on a computer in my schools computer lab, and it complained about that statement as being an invalid use of a nonstatic method.
I googled some articles. Some of which said you have to use 'p = &Dog::bark;' but the compiler issued the same complaint.
Note the pointer declaration worked fine, but the compiler yelled everytime i tried to assign it to something. But again, both 'p = Dog::bark;' and "p = &Dog::bark;' compiled and ran on my home compiler.
So my question is, is the compiler at school behaving improperly, or is my current compiler outdated? IF so, what is the correct way to make p point to a member function?
No problem.
Also, instead of using \sqrt( ) use \sqrt{ } so the root covers everything. Just makes it more readable. Just a suggestion.
vs
oh THATS why thats happening! Thanks, that was really annoying.
argh! mess up! thanks, for the heads up, LuisRodg
(edit) FIXED!
okay, we got up to here
doing the multiplications we obtain
note the h's above and below will cancel so you get
now the quotient rule for limits says the limit of a quotient (or fraction) is equal to the limit of the numerator divided by the limit of the denominator if and only if the denominator is nonzero. I think you will now find that the limit of the denominator is not zero. This means you can basically replace h with zero and evaluate it directly. So take the above limit, replace h with zero, and simplify!
we begin with
filling in for f(a) and f(a +h)
adding the two fractions in the numerator, and multiplying above and below by 1/h we obtain
now try the following, multiply the limit by the fraction shown on the right (the fraction is equal to 1)
from here, you should be able to work it out yourself.
note that
the reason we do this, is because the numerator had the form (a - b), where a and b were both the square root of something, thus if we multiply above and below by (a +b), the numerator becomes (a - b)*(a+b) = a^2 - b^2, the squaring gets rid of the radicals.
whenever you have limits involving radicals, this trick is usually needed to solve it.
While we're on the subject, whats the easiest way to find out how to hit a target thats not level with the firing height?
I use y = x tan(θ) + g/(2u^2) x^2 sec^2 θ, and substitute tan^2 + 1 for sec^. You then have a quadratic equation involving tan θ, and you can solve. It works but its not the fastest thing in the world.
oh come on, Jane. don't beat yourself up!
I appreciate the effort. Now we know it is in fact out of range.
i agree. unsolvable!
I'd say 'reaches the insect' is where that problem gets unclear. APPARENTLY they meant vertical height, but i never would have guessed if i didn't know it was out of range.
ah.. u = 3.56, ok
well look at the graph that produces:
you basically constructed an arc that will peak at the same height as the insect, but doesn't touch it. The insect is at around (7.2, 5.2)
I thought i had established that vertical couldn't happen either but I realize now, i only checked horizontally.
But still, the insect isn't hit!
(edit) sorry that graph link didn't work. Here's a pic.
unless I'm mistaken about what those variables stand for, that gives you θ = sin^-1 ( 1.538) ![]()
i have to take a course in elementary physics for my computer science curriculum. Its pretty easy and mostly stuff I've seen before. But this problem still managed to stump me

I'm convinced now that this problem was a mistake. Based on my calculations, the fish cannot reach the insect with its given firing power, and it also cannot spit a drop in such a way that it peaks directly beneath the insect.
However, i'm also having a bad math day. For some reason i'm making a lot of silly mistakes today. Don't know what it is, but that being the case, I'm not 100% sure this problem was a mistake.
The book claims the answer is 64.8 degrees. I have checked this angle, and my calculations show that the location where the arc reaches its top is neither horizontally nor vertically aligned with the bug. BUT again, i'm having a bad math day so i don't trust myself right now.
So am i going mad or does it have no solution?
I'm no mathmatician, so I'm not sure if there are different kinds of "not equal" signs; one that means unequal no matter what, and one that means not equal at least in one case.
If it means always unequals, then you are right that they are opposites since it is a two-state {0, 1} arena.
first i'm using 1 and 0 to represent the boolean values true and false respectively, thats just notation
the above are all postulates, I think there are probably some axioms that i'm allowed to use. For instance, a boolean value is either true or false. If it isn't false, its true, and vice versa.
when working with variables, the actual values are not given, however you can be sure that either A = B or A ≠ B no matter what values for A and B are being dealt with. If you can show that it works in both cases, then you have proved it in the general case.
But yeah, the question remains, is it okay to say A ≠ B ⇒ A = B'
I think if we are working with boolean values, we have to be able to assume that much, right?
agreed, john. In fact i'm wondering if its okay to say A ≠ B ⇒ A = Not B at this point, or if we need to establish it using other postulates.
does anyone know a way to prove demorgans law without breaking the possibilities into separate cases?
(note i'm using for AND, + for OR and ' for NOT)
suppose these are the postulates you may use:
P1 Boolean algebra is closed under the AND, OR, and NOT operations.
P2 The identity element with respect to is one and + is zero. There is no identity element with respect to logical NOT.
P3 The and + operators are commutative.
P4 and + are distributive with respect to one another. That is, A (B + C) = (A B) + (A C) and A + (B C) = (A + B) (A + C).
P5 For every value A there exists a value A such that AA = 0 and A+A = 1. This value is the logical complement (or NOT) of A.
P6 and + are both associative. That is, (AB)C = A(BC) and (A+B)+C = A+(B+C)
and you may use the following thoerems:
Th1: A + A = A
Th2: A A = A
Th3: A + 0 = A
Th4: A 1 = A
Th5: A 0 = 0
Th6: A + 1 = 1
use all of the above to prove (a + b) = a b
i begin by proving the following lemma:
lemma 1: if A * B' = 0 and A + B' = 1, then A=B
proof by contrapositive: suppose A ≠ B, then A = B' therefore
A*B' = A*A = 0 and by theorem 2,
A = 0, but likewise
A + B' = A+A = 1 and by theorem 2
A+A = A = 1, thus we have A = 1 and A = 0, a contradiction. Thus the lemma is proved.
Now we use this to prove (a + b) = a b
we use the lemma, if A * B' = 0 and A + B' = 1, then A=B
let A = a' * b' and let B = (a + b)'
first we show A * B' = 0
A*B' = (a' * b')*(a + b), using the distributive and commutative postulates,
= a'*a * b' + a'*b'*b now using postulate 5
= 0 * b' + a'* 0, now by theorem 5
= 0 * 0 = 0
now we show A + B' = 1
A + B' = a' * b' + a + b
suppose a = b (this is what i don't like doing
)
then
a' * 'b + a + b = a' * a' + a + a. by theorems 1 and 2,
= a' + a. by postulate 5
= 1
suppose now that a ≠ b, then (and so a = b' and b = a')
then
a' * b' + a + b = a' * a + a + a'. by postulate 5
= 0 + 1 = 1
therefore the lemma applies so A = B, or more specifically, (a + b) = a b qed.
I guess this works but is there any way to avoid breaking it up into cases? If i'm going to use that, i might as well use a truth table to prove it. ![]()
In Brasil, big commotion at night over television funny people named Leno and Letterman.
Many people laugh Leno is funniest, I think Letterman makes best funny joke.
But, say they fought, who fight hard? Leno use chin for strong defense, but Letterman make wind blasts with gap teeth.
Would be fight of ages, I believe.
Who strongerest of funny?
this is HILARIOUS! ![]()
Wow! look at the response this threads getting! ![]()
After a great amount of confusion i've hypothesized that they use the regular binary system to store positive values, and two's complement numbers for negative values.
Two's complement is "regular binary" for positive values. I'm not certain if that's what you were trying to say.
by 'regular binary' i meant place value, as in 1010 = 1*2^3 + 0*2^2 + 1*2^1 + 0*^0 = 12d
What i really think my book is doing is using the ordinary binary system for positive numbers (as in, 1010 = 12d) and using two's complement for negative numbers. I was actually able to prove that there is no overlap so there is no ambiguity between the two.
we are using an online text for this course, and its accesible from anywhere:
http://webster.cs.ucr.edu/AoA/DOS/pdf/0_AoAPDF.html
if you click on chapter 1 and go to the pages 13 of the pdf (not of the actual page numbers) you can find the part on signed numbers and on the next page they do positive to negative conversions.
The reason i think they're using 'place value binary' for positive numbers and 'two's complement' for negatives is because supposedly, you can calculate a numbers negative by using NOT and adding 1. They begin with 5 written as 0101 and then write -5 as 1011. 1011 = 11d which by my understanding, is how we write positive 5 in two's complement form.
also, that pdf never actually told me what two's complement meant and i'm currently under the impression that if x is the value you want to represent (who's binary form has n bits) then
x + complement = 2^n
and we write x in two's complement form by writing 'complement' in binary form.
Thats my understanding of the subject. Care to point out where i'm going wrong, if anywhere?
oops! I'm sorry. I thought i was posting this in coders corner! my bad! ![]()
i'm taking a course in assembly language x_x
I'm reading about how a given computer system stores negative numbers, and they are not being very clear. After a great amount of confusion i've hypothesized that they use the regular binary system to store positive values, and two's complement numbers for negative values.
Supposedly, you can take the negative of a number by using NOT and adding 1
take 3
0011
NOT
1100
add 1
1101 this represents -3?
but that gives us 13, which if i'm not mistaken is the complement of 3, not -3.
is this correct? we store negative values by storing their absolute value in two's complement form?
whoops! i thought i replied to this.
i meant to say a 2 dimensional array in C++ is not an array of 1 dimensional arrays in C++, instead it seems to be stored and handled differently.
Am I not correct?
Check out the STL, specifically the vector class, if you wish to take the "naive" view that a matrix is an array of arrays.
Hold it! I DON'T want to take that view! In fact, stating that a 2 dimensional array is an array of arrays always made me uncomfortable based on syntax and how the compiler treats it.
i agree a matrix is like an array of arrays, but C++ does not seem to agree in terms of syntax.
For instance, you can't just say:
int matrix[3][2];
int * array1 = matrix[1];
int * array2 = matrix[2];
i may have it backwards (requiring 3 array pointers instead of 2) but you get the idea. neither work, and other variations like adding [0] at the end don't work.
Does Luca's suggestion work for you, Ricky? doesn't seem to work properly for me.