|
|
Up |
|
|
  |
Author: subramanian100insubramanian100in
Date: May 5, 2008 22:14
I am copying the following lines as it is, from Stanley Lippman's C++
Primer 4th edition, page 418(First paragraph).
It says:
"Although the map and set types provide bidirectional iterators, we
can use only a subset of the algorithms on associative containers. The
problem is that key in an associative container is const. Hence, any
algorithm that writes to elements in the sequence cannot be used on an
associative container. We may use iterators bound to associative
containers only to supply arguments that will be read."
Here, consider the line "any algorithm that writes to elements in the
sequence cannot be used on an associative container".
Consider the code fragment:
typedef set s_type;
s_type s1;
s_type s2;
// store some values into s1 and s2.
s_type dest;
merge(s1.begin(), s1.end(), s2.begin(), s2.end(),
inserter(dest, dest.end()));
|
| Show full article (1.47Kb) |
|
| |
3 Comments |
|
  |
|
|
  |
|
|
  |
Author: osama178osama178
Date: May 5, 2008 20:40
Hi,
What does it mean for an object to be binary compatible? And why
aren't STL objects binary compatible? Any insights, links, resources
for further reading are greatly appreciated.
Thanks.
|
| |
|
23 Comments |
|
  |
Author: bradbrad
Date: May 5, 2008 14:55
In the example below, possible_number is a string of one or more
digit(s). For example, it may be 4 or 4444. However, when I attempt to
perform the times 2 calculation, the ASCII value of 4 (which is 52) is
used instead of 4 itself. I need to be able to easily reverse the order
of the digits and to only perform this calculation on even positioned
digits... that's why I'm using string instead of int. Any suggestions on
how to make 4*2 = 8 I've tried atoi() type casting, etc. I'm stuck.
Still learning c++.
Thanks for any help!
int position = 0;
|
| Show full article (0.88Kb) |
|
3 Comments |
|
  |
Author: pleatofthepantspleatofthepants
Date: May 5, 2008 13:39
I have a Binary Search Tree and a function called inOrder
void inOrder (TreeNode*, ostream& out)
which is being called like this: a.inOrder(cout);
But it will not work because the parameters are not the same. The
function call has to be the same but what can I change in the function
to allow this?
|
| |
|
1 Comment |
|
  |
|
|
  |
Author: notahipeenotahipee
Date: May 5, 2008 11:42
Would someone be able to tell me why this isn't working. The nested
for loops seem correctly coded to me. I would appreciate any input.
#include
#include
int main ()
{
int a, b, c, d;
cout << "Enter two integers ";
cin >> a >> b;
for (c=a; c==b; c++)
{
for(d=2; d<=sqrt(c); d++)
{
if(c%%d==0)
continue;
|
| Show full article (0.48Kb) |
|
9 Comments |
|
  |
Author: RahulRahul
Date: May 5, 2008 08:19
Hi,
I have the following program,
void dfs(struct node * root)
{
if(root == NULL) return;
std::stack s;
s.push(root);
while(!s.empty())
{
struct node * temp = s.pop();
printf("%%d ",temp->data);
s.push(temp->rptr);
s.push(temp->lptr);
}
}
and i get a error saying,
ro.c: In function `void dfs(node*)':
ro.c:419: `stack' undeclared in namespace `std'
Am i missing something?
|
| Show full article (0.45Kb) |
|
2 Comments |
|
  |
|
|
  |
Author: .rhavin grobert.rhavin grobert
Date: May 5, 2008 06:03
[insert ya favorite greetin' here;-)]
guess you have the following classes...
___________________________________
class {
//..a couple of methods ...//
};
class A {
public:
//...//
B* GetB() // <- this we'll talk about
private:
B* m_pB;
};
A::GetB() {
//..some code..//
return m_pB;
};
___________________________________
when some does a...
|
| Show full article (0.78Kb) |
|
5 Comments |
|
|
|
|
|
|