473,388 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Generic indirection adaptor

Hi,

as a result of my last posting about an adaption class template for
invoking algorithms on a container of iterators or pointers to elements
in another container, I have come up with this code:

#include <vector>
#include <functional>
#include <algorithm>
#include <iostream>

template< typename It, typename Pred >
class indirect_binary: public std::binary_function<It,It,bool>
{
public:
bool operator() (It lhs, It rhs) const {
return Pred() (*lhs, *rhs);
}
};

int main()
{
typedef std::vector<int> IntVec;
typedef IntVec::iterator IntVecIt;

std::vector<int> v1;
v1.push_back(5);
v1.push_back(2);

std::vector<int*> v2;
v2.push_back( &v1[0] );
v2.push_back( &v1[1] );

indirect_binary< int*, std::less<int> > fctor; // note the int*!
std::sort( v2.begin(), v2.end(), fctor );

std::vector<int*>::iterator it = v2.begin();
for( ; it != v2.end(); ++it )
{
std::cout << **it << std::endl;
}
}

Well, it works, output is: 2, 5.
However, you may have noticed that I instantiated the adaptor with int*
instead of IntVecIt. If I do the latter, I get tons of error messages:

deref.cpp: In function `int main()':
deref.cpp:25: error: no matching function for call to `
std::vector<main()::IntVecIt, std::allocator<main()::IntVecIt>
::push_back( int*)'
/usr/include/c++/3.3/bits/stl_vector.h:596: error: candidates are: void
std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp =
main()::IntVecIt, _Alloc = std::allocator<main()::IntVecIt>]
deref.cpp:26: error: no matching function for call to `
std::vector<main()::IntVecIt, std::allocator<main()::IntVecIt>::push_back(

int*)'
/usr/include/c++/3.3/bits/stl_vector.h:596: error: candidates are: void
std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp =
main()::IntVecIt, _Alloc = std::allocator<main()::IntVecIt>]
deref.cpp:31: error: conversion from `
__gnu_cxx::__normal_iterator<main()::IntVecIt*,
std::vector<main()::IntVecIt, std::allocator<main()::IntVecIt> > >' to
non-scalar type `__gnu_cxx::__normal_iterator<int**, std::vector<int*,
std::allocator<int*> > >' requested
deref.cpp:32: error: no match for 'operator!=' in 'it != std::vector<_Tp,
_Alloc>::end() [with _Tp = main()::IntVecIt, _Alloc =
std::allocator<main()::IntVecIt>]()'

And another question: Why do I have to take lhs and rhs by value in
operator() ? If I declare it taking const references, it won't compile
either.

I'd be glad for all your input, because I intend to use this template
class pretty often once it is finished, so I want it to be as robust as
possible.

--
Matthias Kaeppler
Jul 23 '05 #1
15 1576
Matthias Kaeppler wrote:
Hi,

as a result of my last posting about an adaption class template for
invoking algorithms on a container of iterators or pointers to elements
in another container, I have come up with this code:

#include <vector>
#include <functional>
#include <algorithm>
#include <iostream>

template< typename It, typename Pred >
class indirect_binary: public std::binary_function<It,It,bool>
{
public:
bool operator() (It lhs, It rhs) const {
return Pred() (*lhs, *rhs);
}
};

int main()
{
typedef std::vector<int> IntVec;
typedef IntVec::iterator IntVecIt;

std::vector<int> v1;
v1.push_back(5);
v1.push_back(2);

std::vector<int*> v2;
v2.push_back( &v1[0] );
v2.push_back( &v1[1] );

indirect_binary< int*, std::less<int> > fctor; // note the int*!
std::sort( v2.begin(), v2.end(), fctor );

std::vector<int*>::iterator it = v2.begin();
for( ; it != v2.end(); ++it )
{
std::cout << **it << std::endl;
}
}

Well, it works, output is: 2, 5.
However, you may have noticed that I instantiated the adaptor with int*
instead of IntVecIt. If I do the latter, I get tons of error messages:
Your comparison operators gets passed already-dereferenced iterators,
not the iterators themselves.
And another question: Why do I have to take lhs and rhs by value in
operator() ? If I declare it taking const references, it won't compile
either.


Strange, I changed your comparison function to:

bool operator() (const It& lhs, const It& rhs) const {

and it worked fine...

Did you mean something else?

Chris
Jul 23 '05 #2
Chris Jefferson wrote:
Your comparison operators gets passed already-dereferenced iterators,
not the iterators themselves.


What do you mean? Isn't IntVecIt in most cases just a typedef for int*
anyway? At least it is on my implementation. So:

bool operator() (It lhs, It rhs) {
return Pred() (*lhs, *rhs);
}

translates to:

bool operator() (int* lhs, int* rhs) {
return Pred() (*lhs, *rhs);
}

I can't see what's wrong with that.

--
Matthias Kaeppler
Jul 23 '05 #3
Matthias Kaeppler wrote:
Chris Jefferson wrote:
Your comparison operators gets passed already-dereferenced iterators,
not the iterators themselves.

What do you mean? Isn't IntVecIt in most cases just a typedef for int*
anyway? At least it is on my implementation. So:


It isn't on my implementation (gcc 3.3.3). Assuming that it is is a big
no-no!

You can however given an iterator into a vector<int> do &*it and get an
int*. I'm not positive this is guaranteed by the standard, I remember
seeing a defect report about it and can't remember if it got accepted.
I've never seen an implementation where it didn't work.

Chris
Jul 23 '05 #4
Chris Jefferson wrote:
Matthias Kaeppler wrote:
Chris Jefferson wrote:
Your comparison operators gets passed already-dereferenced iterators,
not the iterators themselves.


What do you mean? Isn't IntVecIt in most cases just a typedef for int*
anyway? At least it is on my implementation. So:


It isn't on my implementation (gcc 3.3.3). Assuming that it is is a big
no-no!

You can however given an iterator into a vector<int> do &*it and get an
int*. I'm not positive this is guaranteed by the standard, I remember
seeing a defect report about it and can't remember if it got accepted.
I've never seen an implementation where it didn't work.

Chris


Oh, okay. But is the design of the adaptor okay?

--
Matthias Kaeppler
Jul 23 '05 #5
Matthias Kaeppler wrote:
Chris Jefferson wrote:
Matthias Kaeppler wrote:
Chris Jefferson wrote:

Your comparison operators gets passed already-dereferenced
iterators, not the iterators themselves.


What do you mean? Isn't IntVecIt in most cases just a typedef for
int* anyway? At least it is on my implementation. So:


It isn't on my implementation (gcc 3.3.3). Assuming that it is is a
big no-no!

You can however given an iterator into a vector<int> do &*it and get
an int*. I'm not positive this is guaranteed by the standard, I
remember seeing a defect report about it and can't remember if it got
accepted. I've never seen an implementation where it didn't work.

Chris

Oh, okay. But is the design of the adaptor okay?


Yes, it's good :)

Chris
Jul 23 '05 #6
Oh, one more question:
I want it to work with both functors and functions. However,
"overloading" a template doesn't seem to work (I tried to replace the
second template argument with a pointer to function returning bool and
taking two It::value_typeS).
This however, results in a redefinition error. Okay, so I renamed the
template and tried it this way:

template< typename It >
class indirect_binary_fn: public std::binary_function<It,It,bool>
{
bool (*pred)(It::value_type, It::value_type);
public:
indirect_binary_fn( bool (*f)(It::value_type, It::value_type) )
: pred(f) {}
bool operator() (const It& lhs, const It& rhs) const {
return pred(*lhs, *rhs);
}
};

Error:
deref.cpp:17: error: variable declaration is not allowed here
deref.cpp:19: error: variable declaration is not allowed here
deref.cpp: In constructor `indirect_binary_fn<It>::indirect_binary_fn()':
deref.cpp:19: error: class `indirect_binary_fn<It>' does not have any
field named `pred'

Why am I not allowed to declare that variable?

--
Matthias Kaeppler
Jul 23 '05 #7
Matthias Kaeppler wrote:
Oh, one more question:
I want it to work with both functors and functions. However,
"overloading" a template doesn't seem to work (I tried to replace the
second template argument with a pointer to function returning bool and
taking two It::value_typeS).
This however, results in a redefinition error. Okay, so I renamed the
template and tried it this way:

template< typename It >
class indirect_binary_fn: public std::binary_function<It,It,bool>
{
bool (*pred)(It::value_type, It::value_type); This should be:
// to make life easier, use a typedef
typedef bool (*pred_fn)(typename It::value_type,
typename It::value_type);

pred_fn pred;
public:
indirect_binary_fn( bool (*f)(It::value_type, It::value_type) )
: pred(f) {} Also:
indirect_binary_fn(pred_fn f) : pred(f) {} bool operator() (const It& lhs, const It& rhs) const {
return pred(*lhs, *rhs);
}
};


There is a much better solution though, to allow for both functors and
functions to be called if you use the boost library:

template<class BinaryPredicate>
class indirect_binary_fn : public std::binary_function<typename
boost::binary_traits<BinaryPredicate>::first_argum ent_type,
typename
boost::binary_traits<BinaryPredicate>::second_argu ment_type,
bool> {
private:
typedef typename boost::binary_traits<BinaryPredicate> It;

BinaryPredicate pred;

public:
indirect_binary_fn(BinaryPredicate f) : pred(f) {}
bool operator() (const It& lhs, const It& rhs)const
{ return pred(*lhs, *rhs); }
};

typename boost::binary_traits<BinaryPredicate>::first_argum ent_type and
its brother second_argument_type allow you to get the argument types for
either a function pointer or an AdaptableBinaryPredicate (which you can
get by deriving your functors from std::binary_function). The
definintion is a little spammy I know, but in the end you have a much
more useful indirection functor here.
Jul 23 '05 #8
Kurt Stutsman wrote:
Matthias Kaeppler wrote:
Oh, one more question:
I want it to work with both functors and functions. However,
"overloading" a template doesn't seem to work (I tried to replace the
second template argument with a pointer to function returning bool and
taking two It::value_typeS).
This however, results in a redefinition error. Okay, so I renamed the
template and tried it this way:

template< typename It >
class indirect_binary_fn: public std::binary_function<It,It,bool>
{
bool (*pred)(It::value_type, It::value_type);


This should be:
// to make life easier, use a typedef
typedef bool (*pred_fn)(typename It::value_type,
typename It::value_type);

pred_fn pred;
public:
indirect_binary_fn( bool (*f)(It::value_type, It::value_type) )
: pred(f) {}


Also:
indirect_binary_fn(pred_fn f) : pred(f) {}
bool operator() (const It& lhs, const It& rhs) const {
return pred(*lhs, *rhs);
}
};


There is a much better solution though, to allow for both functors and
functions to be called if you use the boost library:

template<class BinaryPredicate>
class indirect_binary_fn : public std::binary_function<typename
boost::binary_traits<BinaryPredicate>::first_argum ent_type,
typename
boost::binary_traits<BinaryPredicate>::second_argu ment_type,
bool> {
private:
typedef typename boost::binary_traits<BinaryPredicate> It;

BinaryPredicate pred;

public:
indirect_binary_fn(BinaryPredicate f) : pred(f) {}
bool operator() (const It& lhs, const It& rhs)const
{ return pred(*lhs, *rhs); }
};

typename boost::binary_traits<BinaryPredicate>::first_argum ent_type and
its brother second_argument_type allow you to get the argument types for
either a function pointer or an AdaptableBinaryPredicate (which you can
get by deriving your functors from std::binary_function). The
definintion is a little spammy I know, but in the end you have a much
more useful indirection functor here.


Nice, thanks for the great advice. I have already lots of boost'ed code
in my program, so I certainly don't mind to add some more.

I'll report back if still something shouldn't work :)

--
Matthias Kaeppler
Jul 23 '05 #9
Matthias Kaeppler wrote:
Kurt Stutsman wrote:
Matthias Kaeppler wrote:
Oh, one more question:
I want it to work with both functors and functions. However,
"overloading" a template doesn't seem to work (I tried to replace the
second template argument with a pointer to function returning bool
and taking two It::value_typeS).
This however, results in a redefinition error. Okay, so I renamed the
template and tried it this way:

template< typename It >
class indirect_binary_fn: public std::binary_function<It,It,bool>
{
bool (*pred)(It::value_type, It::value_type);

This should be:
// to make life easier, use a typedef
typedef bool (*pred_fn)(typename It::value_type,
typename It::value_type);

pred_fn pred;
public:
indirect_binary_fn( bool (*f)(It::value_type, It::value_type) )
: pred(f) {}

Also:
indirect_binary_fn(pred_fn f) : pred(f) {}
bool operator() (const It& lhs, const It& rhs) const {
return pred(*lhs, *rhs);
}
};


There is a much better solution though, to allow for both functors and
functions to be called if you use the boost library:

template<class BinaryPredicate>
class indirect_binary_fn : public std::binary_function<typename
boost::binary_traits<BinaryPredicate>::first_argum ent_type,
typename
boost::binary_traits<BinaryPredicate>::second_argu ment_type,
bool> {
private:
typedef typename boost::binary_traits<BinaryPredicate> It; Spotted an error in my code. The above line should be:
typedef typename boost::binary_traits<BinaryPredicate>::first_argum ent_type It;
BinaryPredicate pred;

public:
indirect_binary_fn(BinaryPredicate f) : pred(f) {}
bool operator() (const It& lhs, const It& rhs)const
{ return pred(*lhs, *rhs); }
};

typename boost::binary_traits<BinaryPredicate>::first_argum ent_type
and its brother second_argument_type allow you to get the argument
types for either a function pointer or an AdaptableBinaryPredicate
(which you can get by deriving your functors from
std::binary_function). The definintion is a little spammy I know, but
in the end you have a much more useful indirection functor here.

Nice, thanks for the great advice. I have already lots of boost'ed code
in my program, so I certainly don't mind to add some more.

I'll report back if still something shouldn't work :)

Jul 23 '05 #10
Found a couple more problems with my code. Decided to just go ahead and write a little program to
verify my code. Here it is. Notice I added a template function that returns an instance of the
class. This is so you don't have to include the type of the function in the declaration of the functor:

#include <boost/functional.hpp>
#include <functional>
#include <iostream>

template<class BinPred>
class indirect_fn_functor : public std::binary_function<typename
boost::binary_traits<BinPred>::first_argument_type ,
typename
boost::binary_traits<BinPred>::second_argument_typ e,
bool> {
private:
typedef typename boost::binary_traits<BinPred>::first_argument_type It;

BinPred pred;

public:
indirect_fn_functor(BinPred f) : pred(f) {}
bool operator() (const It* lhs, const It* rhs)const
{ return pred(*lhs, *rhs); }
};

template<class BinPred>
indirect_fn_functor<BinPred> indirect_fn(BinPred pred)
{
return indirect_fn_functor<BinPred>(pred);
}

bool intLessThan(int lhs, int rhs)
{
return lhs < rhs;
}

bool intGreaterThan(int lhs, int rhs)
{
return lhs > rhs;
}

int main()
{
int a = 1;
int b = 2;

std::cout << "1 < 2: " << indirect_fn(intLessThan)(&a, &b) << "\n";
std::cout << "1 < 2: " << indirect_fn(std::less<int>())(&a, &b) << "\n";

std::cout << "1 > 2: " << indirect_fn(intGreaterThan)(&a, &b) << "\n";
std::cout << "1 > 2: " << indirect_fn(std::greater<int>())(&a, &b) << "\n";
return 0;
}
Jul 23 '05 #11
Kurt Stutsman wrote:
#include <boost/functional.hpp>
#include <functional>
#include <iostream>

template<class BinPred>
class indirect_fn_functor : public std::binary_function<typename
boost::binary_traits<BinPred>::first_argument_type ,
typename
boost::binary_traits<BinPred>::second_argument_typ e,
bool> {
private:
typedef typename
boost::binary_traits<BinPred>::first_argument_type It;

BinPred pred;

public:
indirect_fn_functor(BinPred f) : pred(f) {}
bool operator() (const It* lhs, const It* rhs)const
{ return pred(*lhs, *rhs); }
};

template<class BinPred>
indirect_fn_functor<BinPred> indirect_fn(BinPred pred)
{
return indirect_fn_functor<BinPred>(pred);
}

bool intLessThan(int lhs, int rhs)
{
return lhs < rhs;
}

bool intGreaterThan(int lhs, int rhs)
{
return lhs > rhs;
}

int main()
{
int a = 1;
int b = 2;

std::cout << "1 < 2: " << indirect_fn(intLessThan)(&a, &b) << "\n";
std::cout << "1 < 2: " << indirect_fn(std::less<int>())(&a, &b)
<< "\n";

std::cout << "1 > 2: " << indirect_fn(intGreaterThan)(&a, &b) <<
"\n";
std::cout << "1 > 2: " << indirect_fn(std::greater<int>())(&a,
&b) << "\n";
return 0;
}


Okay, hm, some questions coming to my mind:

This line:
typedef typename boost::binary_traits<BinPred>::first_argument_type It;

bothers me for example. If BinPred is std::less<int> for example, then
binary_traits<BinPred>::first_argument_type is int, not an iterator
type, or am I missing something? ^^

Furthermore, why are you passing the BinPred's by value? I guess this
ends up in a lot of copying?

--
Matthias Kaeppler
Jul 23 '05 #12
Kurt Stutsman wrote:
Found a couple more problems with my code. Decided to just go ahead and
write a little program to verify my code. Here it is. Notice I added a
template function that returns an instance of the class. This is so you
don't have to include the type of the function in the declaration of the
functor:

#include <boost/functional.hpp>
#include <functional>
#include <iostream>

template<class BinPred>
class indirect_fn_functor : public std::binary_function<typename
boost::binary_traits<BinPred>::first_argument_type ,
typename
boost::binary_traits<BinPred>::second_argument_typ e,
bool> {
private:
typedef typename
boost::binary_traits<BinPred>::first_argument_type It;

BinPred pred;

public:
indirect_fn_functor(BinPred f) : pred(f) {}
bool operator() (const It* lhs, const It* rhs)const
{ return pred(*lhs, *rhs); }
};

template<class BinPred>
indirect_fn_functor<BinPred> indirect_fn(BinPred pred)
{
return indirect_fn_functor<BinPred>(pred);
}

bool intLessThan(int lhs, int rhs)
{
return lhs < rhs;
}

bool intGreaterThan(int lhs, int rhs)
{
return lhs > rhs;
}

int main()
{
int a = 1;
int b = 2;

std::cout << "1 < 2: " << indirect_fn(intLessThan)(&a, &b) << "\n";
std::cout << "1 < 2: " << indirect_fn(std::less<int>())(&a, &b)
<< "\n";

std::cout << "1 > 2: " << indirect_fn(intGreaterThan)(&a, &b) <<
"\n";
std::cout << "1 > 2: " << indirect_fn(std::greater<int>())(&a,
&b) << "\n";
return 0;
}


Another point is, that it now doesn't work with iterators anymore, since
operator() now explicitly takes pointers. So the indirection on a
container of iterators won't work.

--
Matthias Kaeppler
Jul 23 '05 #13
Okay, based on your code, I have come up with this:

template< typename Operation >
class indirecter_binary
: public std::binary_function< typename
boost::binary_traits<Operation>::first_argument_ty pe,
typename boost::binary_traits<Operation>::second_argument_t ype,
typename boost::binary_traits<Operation>::result_type >
{
typedef typename
boost::binary_traits<Operation>::first_argument_ty pe arg1_type;
typedef typename
boost::binary_traits<Operation>::second_argument_t ype arg2_type;
typedef typename boost::binary_traits<Operation>::result_type
result_type;
const Operation op;
public:
explicit indirecter_binary( Operation o ): op(o) {}
result_type operator() (arg1_type *lhs, arg2_type *rhs) const {
return op(*lhs, *rhs);
}
};

To make this also work on containers of iterators, I guess it's best to
write a separate class template and separate between e.g.
ptr_indirecter_binary and iter_indirecter_binary?

Or can anyone come up with an idea how to make the adaptor work on both
pointers and iterators? The problem is, I can't do something like
typedef typename arg1_type::iterator ItType;
because that obviously won't work on types which don't define a nested
iterator type.

--
Matthias Kaeppler
Jul 23 '05 #14
Matthias Kaeppler wrote:
Okay, based on your code, I have come up with this:

template< typename Operation >
class indirecter_binary
: public std::binary_function< typename
boost::binary_traits<Operation>::first_argument_ty pe,
typename
boost::binary_traits<Operation>::second_argument_t ype,
typename boost::binary_traits<Operation>::result_type >
{
typedef typename
boost::binary_traits<Operation>::first_argument_ty pe arg1_type;
typedef typename
boost::binary_traits<Operation>::second_argument_t ype arg2_type;
typedef typename boost::binary_traits<Operation>::result_type
result_type;
correction here:

typedef typename boost::binary_traits<Operation>::function_type
function_type;
function_type op;
public:
explicit indirecter_binary( Operation o ): op(o) {}
result_type operator() (arg1_type *lhs, arg2_type *rhs) const {
return op(*lhs, *rhs);
}
};


Weird that it worked even without using function_type (I just tried it)!
But this should be the correct usage.

--
Matthias Kaeppler
Jul 23 '05 #15
Matthias Kaeppler wrote:
Kurt Stutsman wrote:
#include <boost/functional.hpp>
#include <functional>
#include <iostream>

template<class BinPred>
class indirect_fn_functor : public std::binary_function<typename
boost::binary_traits<BinPred>::first_argument_type ,
typename
boost::binary_traits<BinPred>::second_argument_typ e,
bool> {
private:
typedef typename
boost::binary_traits<BinPred>::first_argument_type It;

BinPred pred;

public:
indirect_fn_functor(BinPred f) : pred(f) {}
bool operator() (const It* lhs, const It* rhs)const
{ return pred(*lhs, *rhs); }
};

template<class BinPred>
indirect_fn_functor<BinPred> indirect_fn(BinPred pred)
{
return indirect_fn_functor<BinPred>(pred);
}

bool intLessThan(int lhs, int rhs)
{
return lhs < rhs;
}

bool intGreaterThan(int lhs, int rhs)
{
return lhs > rhs;
}

int main()
{
int a = 1;
int b = 2;

std::cout << "1 < 2: " << indirect_fn(intLessThan)(&a, &b) <<
"\n";
std::cout << "1 < 2: " << indirect_fn(std::less<int>())(&a,
&b) << "\n";

std::cout << "1 > 2: " << indirect_fn(intGreaterThan)(&a, &b)
<< "\n";
std::cout << "1 > 2: " << indirect_fn(std::greater<int>())(&a,
&b) << "\n";
return 0;
}

Okay, hm, some questions coming to my mind:

This line:
typedef typename boost::binary_traits<BinPred>::first_argument_type It;

bothers me for example. If BinPred is std::less<int> for example, then
binary_traits<BinPred>::first_argument_type is int, not an iterator
type, or am I missing something? ^^

Yes it wasn't meant to work on iterators.

Furthermore, why are you passing the BinPred's by value? I guess this
ends up in a lot of copying?

Because functors are typically empty classes with just a operator(). So I think the standard says
you have to at least allocate 1 byte for an empty structure. Either way, it probably will be
optimized into a register. Same with a pointer. This is also how the standard C++ library handles
its algorithms that take functions and functors.
Jul 23 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott Smedley | last post by:
Hi all, I'm trying to write a special adaptor iterator for my program. I have *almost* succeeded, though it fails under some circumstances. See the for-loop in main(). Any pointers/help...
3
by: Stanislaw Salik | last post by:
Hi, Lets suppose we want to use generic algotithms on collections of pointers (both raw and smart). For example, we want to sort a vector of (smart)pointers. We need a comparator that will take...
3
by: Matthias Kaeppler | last post by:
Hello, I need to sort a range of pointers with a predicate which applies to the pointees. I tried to use boost::indirect_iterator, however, this will sort the container with the pointees instead...
1
by: Tony Johansson | last post by:
Hello! I'm reading about design pattern adaptor in the GOF book and there is something that sounds strange. When you use the adaptor design pattern you have these participants. *Target -...
0
by: Tony Johansson | last post by:
Hello!! This is about the adaptor design pattern. If you use the class adaptor its easy to override. It says an object adaptor makes it harder to override Adaptee behavior. It will require...
2
by: 3nc0d3d | last post by:
I have needed to cast a pointer with different types for get a value. I have try to use generic, but there are cast exception. For example the following method: generic<typename T> void...
9
by: mps | last post by:
I want to define a class that has a generic parameter that is itself a generic class. For example, if I have a generic IQueue<Tinterface, and class A wants to make use of a generic class that...
7
by: juerg.lemke | last post by:
Hi everyone I am interested in having multiple functions with different prototypes and deciding, by setting a pointer, which of them to use later in the program. Eg: int f1(void); char*...
3
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.