473,795 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STL: copy vector of class ?

could someone please show/help me to copy all element from "class dog"
to "class new_dog" ?
Note: "class new_dog" has new element "age" which should have value
"my_age"
/////////////////////////////// source code
///////////////////////////////
#include<iostre am>
#include <string>
#include<vector >
#include<sstrea m>
#include<fstrea m>
#include<numeri c>
using namespace std;

class dog
{
public:
string name;
int id;
int YearBorn;
string type;
};

class new_dog
{
public:
string name;
int id;
string age;
string type;
};

#define goldenretriever 11
#define Lab 33
#define Boxer 44
#define Terrier 55
int const CurrentYear =2006;

int dog_name (const string& name,const string& type ,const int age);
int main()
{
vector<dog> v;
vector<new_dog> v2;

new_dog dog_type;
dog dog_class;

ifstream in ("test5e.txt ");
string line;
while (!getline(in,li ne).eof()){
if (line.find("#") !=std::string:: npos)continue;
istringstream is(line);
if(is>>dog_clas s.name>>dog_cla ss.id>>dog_clas s.YearBorn>>dog _class.type)
{
v.push_back(dog _class);
}
}
vector<dog>::it erator search;
for (search=v.begin ();search!=v.en d();++search){
int my_age;
switch (search->id){
case goldenretriever :
my_age =dog_name(searc h->name,search->type,search->YearBorn);
//cout << "My dog is: "<<search->name<< " Age is :"<<
my_age<<endl;
break;
case Lab:
my_age=dog_name (search->name,search->type,search->YearBorn);
break;
case Boxer:
my_age=dog_name (search->name,search->type,search->YearBorn);
break;
case Terrier:
my_age=dog_name (search->name,search->type,search->YearBorn);
break;
default:
break;
} //switch

cout << "Dog name is: "<<search->name<< " ,Age is :"<<
my_age<<endl;
} // for loop

return 0;

}
int dog_name (const string& name,const string& type,int YearBorn){

return (CurrentYear-YearBorn);
}

/////////// input file "test5e.txt " //////////////////////////////

############### ############### ##########
#Name ID YearBorn Type
############### ############### ##########
Cricket 11 2000 GoldenRetriever
Nitro 11 1999 GoldenRetriever
Maxtor 33 2004 Lab
Arron 44 2001 Boxer
#Arron 44 2002 Boxer
Dora 55 2000 Terrier

Jan 24 '06 #1
18 2901
In article <11************ **********@g43g 2000cwa.googleg roups.com>,
"sd2004" <tv****@hotmail .com> wrote:
could someone please show/help me to copy all element from "class dog"
to "class new_dog" ?


The short answer is, don't do that. Make a member-function in the dog
class that accepts the current year as a parameter and returns the dog's
age.

I suspect this is a homework question so I won't give you the whole
answer, but I do want to help out.

int dog::age_at( int year ) { return year - year_born; }

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Jan 24 '06 #2

Daniel T. wrote:
In article <11************ **********@g43g 2000cwa.googleg roups.com>,
"sd2004" <tv****@hotmail .com> wrote:
could someone please show/help me to copy all element from "class dog"
to "class new_dog" ?


The short answer is, don't do that. Make a member-function in the dog
class that accepts the current year as a parameter and returns the dog's
age.

I suspect this is a homework question so I won't give you the whole
answer, but I do want to help out.

int dog::age_at( int year ) { return year - year_born; }


It makes absolutely no sense to have such a method in the interface of
'dog'. You need a method to return the 'yearOfBirth' of the dog (set at
construction), and then you can do whatever math you want with it.

Jan 24 '06 #3

"sd2004" <tv****@hotmail .com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
| could someone please show/help me to copy all element from "class dog"
| to "class new_dog" ?
| Note: "class new_dog" has new element "age" which should have value
| "my_age"

Since you are taking an old class and adding features, why not inherit?
Isn't new_dog still a dog? (is_a relationship). In so far as age is
concerned, shouldn't that be a member function of the new_dog class
instead of a variable that needs to be modified on a specific birthday
for each instance? Isn't age() a new feature that should be deduced
dynamically based on a current date?

class Dog
{
const std::string name;
const int id;
const int YearBorn;
const std::string type;
public:
Dog(std::string s, int n, int y, std::string t); // hint: init list
virtual ~Dog();
/* member functions */
std::string getName() const;
int getID() const;
int getYearBorn() const;
std::string getType() const;
};

class NewDog : public Dog
{
public:
NewDog(std::str ing s, int n, int y, std::string t) : Dog(s, n, y, t)
{ }
~NewDog() { }
/* member functions */
int getAge(const int currentyear) const
{
return currentyear - getYearBorn();
}
};

|
| class new_dog
| {
| public:
| string name;
| int id;
| string age;
| string type;
| };
| /////////////////////////////// source code
| ///////////////////////////////
| #include<iostre am>
| #include <string>
| #include<vector >
| #include<sstrea m>
| #include<fstrea m>
| #include<numeri c>
| using namespace std;
|
| class dog
| {
| public:
| string name;
| int id;
| int YearBorn;
| string type;
| };
|
| class new_dog
| {
| public:
| string name;
| int id;
| string age;
| string type;
| };
|
| #define goldenretriever 11
| #define Lab 33
| #define Boxer 44
| #define Terrier 55
| int const CurrentYear =2006;
|
| int dog_name (const string& name,const string& type ,const int age);
| int main()
| {
| vector<dog> v;
| vector<new_dog> v2;
|
| new_dog dog_type;
| dog dog_class;
|
| ifstream in ("test5e.txt ");
| string line;
| while (!getline(in,li ne).eof()){
| if (line.find("#") !=std::string:: npos)continue;
| istringstream is(line);
|
if(is>>dog_clas s.name>>dog_cla ss.id>>dog_clas s.YearBorn>>dog _class.type)
| {
| v.push_back(dog _class);
| }
| }
| vector<dog>::it erator search;
| for (search=v.begin ();search!=v.en d();++search){
| int my_age;
| switch (search->id){
| case goldenretriever :
| my_age =dog_name(searc h->name,search->type,search->YearBorn);
| //cout << "My dog is: "<<search->name<< " Age is :"<<
| my_age<<endl;
| break;
| case Lab:
| my_age=dog_name (search->name,search->type,search->YearBorn);
| break;
| case Boxer:
| my_age=dog_name (search->name,search->type,search->YearBorn);
| break;
| case Terrier:
| my_age=dog_name (search->name,search->type,search->YearBorn);
| break;
| default:
| break;
| } //switch
|
| cout << "Dog name is: "<<search->name<< " ,Age is :"<<
| my_age<<endl;
|
|
| } // for loop
|
| return 0;
|
| }
| int dog_name (const string& name,const string& type,int YearBorn){
|
| return (CurrentYear-YearBorn);
| }
|
| /////////// input file "test5e.txt " //////////////////////////////
|
| ############### ############### ##########
| #Name ID YearBorn Type
| ############### ############### ##########
| Cricket 11 2000 GoldenRetriever
| Nitro 11 1999 GoldenRetriever
| Maxtor 33 2004 Lab
| Arron 44 2001 Boxer
| #Arron 44 2002 Boxer
| Dora 55 2000 Terrier
|
Jan 24 '06 #4
I modified the source code as recommend by the expert as far as I
understood.
However , the compiler still give me error, could someone please help.
/////////////////// ERROR MESSAGE ////////////////////////////////

bash-2.05b$ g++ test5f.cpp
test5f.cpp: In function `int main()':
test5f.cpp:48: error: no matching function for call to
`std::vector<do g,
std::allocator< dog> >::push_back(in t)'
/usr/include/c++/3.3.3/bits/stl_vector.h:59 6: error: candidates are:
void
std::vector<_Tp , _Alloc>::push_b ack(const _Tp&) [with _Tp = dog,
_Alloc =
std::allocator< dog>]
test5f.cpp:52: error: no matching function for call to
`std::vector<do g,
std::allocator< dog> >::push_back(in t)'
/usr/include/c++/3.3.3/bits/stl_vector.h:59 6: error: candidates are:
void
std::vector<_Tp , _Alloc>::push_b ack(const _Tp&) [with _Tp = dog,
_Alloc =
std::allocator< dog>]
test5f.cpp:56: error: no matching function for call to
`std::vector<do g,
std::allocator< dog> >::push_back(in t)'
/usr/include/c++/3.3.3/bits/stl_vector.h:59 6: error: candidates are:
void
std::vector<_Tp , _Alloc>::push_b ack(const _Tp&) [with _Tp = dog,
_Alloc =
std::allocator< dog>]
test5f.cpp:60: error: no matching function for call to
`std::vector<do g,
std::allocator< dog> >::push_back(in t)'
/usr/include/c++/3.3.3/bits/stl_vector.h:59 6: error: candidates are:
void
std::vector<_Tp , _Alloc>::push_b ack(const _Tp&) [with _Tp = dog,
_Alloc =
std::allocator< dog>]
bash-2.05b$

/////////////////////////// source code //////////////////////////
#include<iostre am>
#include <string>
#include<vector >
#include<sstrea m>
#include<fstrea m>
#include<numeri c>
using namespace std;

class dog
{
public:
string name;
int id;
int YearBorn;
string type;
int age (const int year );
};
#define goldenretriever 11
#define Lab 33
#define Boxer 44
#define Terrier 55
int const CurrentYear =2006;

int dog_age (const string& name,const string& type ,const int age);
int main()
{
vector<dog> v;

dog dog_class;

ifstream in ("test5f.txt ");
string line;
while (!getline(in,li ne).eof()){
if (line.find("#") !=std::string:: npos)continue;
istringstream is(line);
if(is>>dog_clas s.name>>dog_cla ss.id>>dog_clas s.YearBorn>>dog _class.type)
{
v.push_back(dog _class);
}
}
vector<dog>::it erator search;
for (search=v.begin ();search!=v.en d();++search){
int my_age;
switch (search->id){
case goldenretriever :
v.push_back(dog _class.age(sear ch->YearBorn)); //line 48
//dog_class.age(s earch->YearBorn);
break;
case Lab:
v.push_back(dog _class.age(sear ch->YearBorn)); //line 52
//dog_class.age(s earch->YearBorn);
break;
case Boxer:
v.push_back(dog _class.age(sear ch->YearBorn)); // line 56
//dog_class.age(s earch->YearBorn);
break;
case Terrier:
v.push_back(dog _class.age(sear ch->YearBorn)); // line 60
//dog_class.age(s earch->YearBorn);
break;
default:
break;
}

}

vector<dog>::it erator i;
for (i=v.begin();i! =v.end();++i){
//cout << "NEW Dog name: " <<i->e << " NEW Age: "<< i->age <<endl;
}
return 0;

}
int dog::age (const int year)
{
return (CurrentYear-YearBorn);
}

Jan 24 '06 #5

"sd2004" <tv****@hotmail .com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
| I modified the source code as recommend by the expert as far as I
| understood.
| However , the compiler still give me error, could someone please help.
| /////////////////// ERROR MESSAGE ////////////////////////////////
|
| bash-2.05b$ g++ test5f.cpp
| test5f.cpp: In function `int main()':
| test5f.cpp:48: error: no matching function for call to
| `std::vector<do g,
| std::allocator< dog> >::push_back(in t)'

I'm no expert but if you don't show minimum code, noone can help. You
should be pushing back the result of a NewDog ctor invocation into the
std::vector container, see main() below. ie:
dogs.push_back( NewDog("name", id, year, "type") );

I've left out the assignment operators for brevity and did not seperate
the headers and source for the same reason. Don't inject the code into
your project, learn the language instead (its worth it since very little
work is involved for considerable results). One doesn't construct a
moving car if he can't first construct one of its wheels. Run in debug
with breakpoints until you get it.

// Proj_Dog.cpp
#include <iostream>
#include <ostream>
#include <string>
#include <vector>

class Dog
{
std::string name;
int id;
int yearborn;
std::string type;
public:
/* ctor */
Dog(std::string s, int n, int y, std::string t)
: name(s), id(n), yearborn(y), type(t) { }
/* copy ctor */
Dog(const Dog& copy)
{
name = copy.name;
id = copy.id;
yearborn = copy.yearborn;
type = copy.type;
}
/* d~tor */
virtual ~Dog() { }
/* member functions */
std::string getName() const { return name; }
int getID() const { return id; }
int getYearBorn() const { return yearborn; }
std::string getType() const { return type; }
};

class NewDog : public Dog
{
public:
/* ctor */
NewDog(std::str ing s, int n, int y, std::string t) : Dog(s, n, y, t)
{ }
/* copy ctor */
NewDog(const NewDog& copy) : Dog(copy) { }
/* d~tor */
~NewDog() { }
/* member functions */
int getAge(const int currentyear) const
{
return currentyear - getYearBorn();
}
/* friend operators */
friend std::ostream& operator<<(std: :ostream&, const NewDog&);
};

std::ostream& operator<<(std: :ostream& os, const NewDog& nd)
{
os << "name:" << nd.getName();
os << " id:" << nd.getID();
os << " yearborn:" << nd.getYearBorn( );
os << " type:" << nd.getType();
return os;
}

int main()
{
int id(0);
std::vector<New Dog> dogs; // our container
dogs.push_back( NewDog("dog_1", ++id, 2001, "type_1") );
dogs.push_back( NewDog("dog_2", ++id, 2002, "type_2") );
dogs.push_back( NewDog("dog_3", ++id, 2003, "type_3") );
dogs.push_back( NewDog("dog_4", ++id, 2004, "type_4") );

int year(2006); // the current year
typedef std::vector<New Dog>::iterator Iter;
Iter it = dogs.begin();
for (it; it != dogs.end(); ++it)
{
std::cout << *it;
std::cout << " age: " << (*it).getAge(ye ar) << std::endl;
}
return 0;
}

/*
name:dog_1 id:1 yearborn:2001 type:type_1 age: 5
name:dog_2 id:2 yearborn:2002 type:type_2 age: 4
name:dog_3 id:3 yearborn:2003 type:type_3 age: 3
name:dog_4 id:4 yearborn:2004 type:type_4 age: 2
*/

obviously, the result of age is dependent on the value assigned to year.
Can you see how simple the exercise becomes once you friendify and
overload the global operator<< for a NewDog?

Now expand the NewDog class to serialize data to and from a file using
the same principle. Perhaps read(std::strin g& filename) and write(...)
might fit the bill.

Jan 25 '06 #6
In article <11************ *********@o13g2 000cwo.googlegr oups.com>,
da********@warp mail.net wrote:
Daniel T. wrote:
In article <11************ **********@g43g 2000cwa.googleg roups.com>,
"sd2004" <tv****@hotmail .com> wrote:
could someone please show/help me to copy all element from "class dog"
to "class new_dog" ?


The short answer is, don't do that. Make a member-function in the dog
class that accepts the current year as a parameter and returns the dog's
age.

I suspect this is a homework question so I won't give you the whole
answer, but I do want to help out.

int dog::age_at( int year ) { return year - year_born; }


It makes absolutely no sense to have such a method in the interface of
'dog'. You need a method to return the 'yearOfBirth' of the dog (set at
construction), and then you can do whatever math you want with it.


Any algorithm that is used to determine the dog's age, should probably
also check for things like negative age, and probably also check to see
if the dog died before that year (and thus never reached that age.) In
other words, in a real program the algorithm would probably be much more
complicated that simply subtracting one number from another. Even if it
isn't, if the dog's age is needed in more than one place, "it makes
absolutely no sense" to duplicate the code required to determine the
dog's age. In that case the code should be placed in a function. Now,
where should that function be placed? The most logical place is in the
Dog class.

So yes, in any but the most simple programs, it does make sense to have
an age like function in the Dog class.
Jan 26 '06 #7

Daniel T. wrote:
In article <11************ *********@o13g2 000cwo.googlegr oups.com>,
da********@warp mail.net wrote:
Daniel T. wrote:
In article <11************ **********@g43g 2000cwa.googleg roups.com>,
"sd2004" <tv****@hotmail .com> wrote:

> could someone please show/help me to copy all element from "class dog"
> to "class new_dog" ?

The short answer is, don't do that. Make a member-function in the dog
class that accepts the current year as a parameter and returns the dog's
age.

I suspect this is a homework question so I won't give you the whole
answer, but I do want to help out.

int dog::age_at( int year ) { return year - year_born; }


It makes absolutely no sense to have such a method in the interface of
'dog'. You need a method to return the 'yearOfBirth' of the dog (set at
construction), and then you can do whatever math you want with it.


Any algorithm that is used to determine the dog's age, should probably
also check for things like negative age, and probably also check to see
if the dog died before that year (and thus never reached that age.) In
other words, in a real program the algorithm would probably be much more
complicated that simply subtracting one number from another. Even if it
isn't, if the dog's age is needed in more than one place, "it makes
absolutely no sense" to duplicate the code required to determine the
dog's age. In that case the code should be placed in a function. Now,
where should that function be placed? The most logical place is in the
Dog class.


The proposed function is

int dog::age_at( int year ) { return year - year_born; }

This is a utility function, and belongs in something like DogUtil:

struct DogUtil {
//...

static int ageAt(const Dog& dog, int year);
// Return the non-negative age of the specified 'dog' in the
// specified 'year'. Return a negative value is 'year < 0', or
// 'year' is less than the year of birth of 'dog'.
};

A candidate member function might be

class Dog {
//...
public:
//...
int age() const;
// Return the current age of this dog.
};

Do you see the difference?

Jan 28 '06 #8
In article <11************ **********@g49g 2000cwa.googleg roups.com>,
da********@warp mail.net wrote:
The proposed function is

int dog::age_at( int year ) { return year - year_born; }

This is a utility function, and belongs in something like DogUtil:

struct DogUtil {
//...

static int ageAt(const Dog& dog, int year);
// Return the non-negative age of the specified 'dog' in the
// specified 'year'. Return a negative value is 'year < 0', or
// 'year' is less than the year of birth of 'dog'.
};
Will you agree with me that a dog's age is a piece of data that is
associated with the dog? If so, why is some other class providing that
data? And if not, why is it the *dog's* age?

What data is associated with DogUtil, or is it just a bag of functions?
A candidate member function might be

class Dog {
//...
public:
//...
int age() const;
// Return the current age of this dog.
};


The above would only work if the Dog class has a dependency on something
that can provide today's date. There's nothing wrong with that if there
are several Dog member-functions that also need to know today's date,
otherwise it is inappropriate. If this is the only member-function that
needs a date to produce the output, then it should accept the date as a
parameter.

My original proposed function has the added bonus of letting the client
determine the age of the dog at any particular year, whereas the
member-function you are proposing can only tell the "current age" of the
dog.
Jan 28 '06 #9
Daniel T. wrote:
Any algorithm that is used to determine the dog's age, should probably
also check for things like negative age, and probably also check to see
if the dog died before that year (and thus never reached that age.) In
other words, in a real program the algorithm would probably be much more
complicated that simply subtracting one number from another.
and:
da********@warp mail.net wrote:
The proposed function is

int dog::age_at( int 5year ) { return year - year_born; }

This is a utility function, and belongs in something like DogUtil:

struct DogUtil {
//...

static int ageAt(const Dog& dog, int year);
// Return the non-negative age of the specified 'dog' in the
// specified 'year'. Return a negative value is 'year < 0', or
// 'year' is less than the year of birth of 'dog'.
};


Will you agree with me that a dog's age is a piece of data that is
associated with the dog? If so, why is some other class providing that
data? And if not, why is it the *dog's* age?


Your proposal means to increase the number of members for the dog class
without sufficient cause. The proposed member yearOfBirth() provides all
necessary information and is a primitive, in terms of which other functions
can be defined. The proposed age() member lacks that property, in
particular if it would incorporate sanity checks like making sure the
result is non-negative.

Would you also opt for a member function

bool isOlderThan ( dog const & other );

or should that be a free standing function:

bool isOlder ( dog const & a, dog const & b ;

How would you implement it in terms of age() or in terms of yearOfBirth().
Note that there is a subtle difference between

bool isOlder( dog const & a, dog const & b ) {
return( a.yearOfBirth() < b.yearOfBirth() );
}

and

bool isOlderThan( dog const & a, dog const & b ) {
return( a.age( 0 ) > b.age( 0 ) );
}

namely that a.age(0) might throw since it is likely to yield a negative
result, at least for dogs born recently. Now, which year would you pick
instead of 0? If you have age also check whether the dog died already, you
are in even more trouble.

Of course, you could have both: a yearOfBirth() member and an age() member.
But where do you stop? Are you willing to add members to the dog class each
time some other piece of code would find those handy? Freestanding
functions can be added any time without the need to change the header
dog.h. That is, why I would opt for a primitive like yearOfBirth() instead
of an age() member function.
Best

Kai-Uwe Bux
Jan 28 '06 #10

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

Similar topics

2
3747
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into the appropriate array. For instance if I receive a RCVD_MSG1, I'll copy into msg1 . Upon receipt of the next RCVD_MSG1. I'll copy into msg1 . The Retrieve function when called should retrieve the latest copy. ie. msg1 or msg1 .
8
2217
by: Generic Usenet Account | last post by:
To settle the dispute regarding what happens when an "erase" method is invoked on an STL container (i.e. whether the element is merely removed from the container or whether it also gets deleted in the process), I looked up the STL code. Erase certainly does not delete the memory associated with the element. However, it appears that the destructor on the element is invoked. I wonder why it has to be this way. In my opinion, this renders...
25
2280
by: rokia | last post by:
in a project, I use many,many stl such as stack,list,vctor etc. somewhere the vector's size is more than 2K. is this a efficient way?
9
1889
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. Here's the question: I want to be able to change the references (including deleting them). Is there any way to do that besides using pointers rather than references for the STL library? I'd also prefer to avoid using const_cast, if it is indeed...
11
2907
by: Richard Thompson | last post by:
I've got a memory overwrite problem, and it looks as if a vector has been moved, even though I haven't inserted or deleted any elements in it. Is this possible? In other words, are there any circumstances in which the STL will move a vector, or invalidate iterators to elements in the vector, if you don't insert or remove elements? My actual problem seems to be as follows: I have class X, which contains an STL vector. The constructor...
35
2653
by: Jon Slaughter | last post by:
I'm having a problem allocating some elements of a vector then deleting them. Basicaly I have something like this: class base { private: std::vector<object> V;
11
4757
by: ma740988 | last post by:
I'm perusing a slide with roughly 12 bullets spread across 3 pages. Each bullet reflects 'advice'. I'm ok with all but 1 bullet, more specifically the bullet that states: " Avoid the STL unless absolutely necessary " Now, I'm not acclimated with much C++ history, but something tells me this is akin to trepidation that surrounded C++ during it's inception? IOW, is this 'old school' rhetoric or ..... How do you refute this argument?
4
1780
by: Generic Usenet Account | last post by:
I am seeing some unexpected behavior while using the STL "includes" algorithm. I am not sure if this is a bug with the template header files in our STL distribution, or if this is how it should work. For your benefit, let me first quote from the STL Standard Reference (Stepanov & Lee): template <class InputIterator1, class InputIterator2> bool includes(InputIterator1 first1, InputIterator1 last1,InputIterator2 first2, InputIterator2...
1
3076
by: krunalbauskar | last post by:
Hi, Explicit instantiation of STL vector demands explicit instantiation of all the templates it using internally. For example - <snippet> #include <iostream> #include <vector>
6
3936
by: Peng Yu | last post by:
Hi, I'm wondering if the following assignment is lazy copy or not? Thanks, Peng std::vector<intv. v.push_back(1); v.push_back(2);
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.