| | |
Class Vectorization requirements
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2005
Posts: 244
Reputation:
Solved Threads: 5
One last question:
One of the employees informed me that nesting structs inside the class was not good coding practice. How should I clean it up?
Should I:
Make new classes from the structs
Typedef the structs
or do something else?
I prefer the way it is right now, because it makes sense for a class called 'Packet' to have the full packet representation and all associated information...
One of the employees informed me that nesting structs inside the class was not good coding practice. How should I clean it up?
Should I:
Make new classes from the structs
Typedef the structs
or do something else?
I prefer the way it is right now, because it makes sense for a class called 'Packet' to have the full packet representation and all associated information...
•
•
•
•
Originally Posted by Drowzee
One of the employees informed me that nesting structs inside the class was not good coding practice. How should I clean it up?
Instead of this:
#if !defined(AFX_TRY5DOC_H__BA63042D_EFBE_45CF_A864_A01C9FB8E010__INCLUDED_)
#define AFX_TRY5DOC_H__BA63042D_EFBE_45CF_A864_A01C9FB8E010__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <vector>
class CPacket //Encapsulates data structs and associated information for easier instantiation.
{
public:
CPacket();
virtual ~CPacket();
bool operator<(const char* str); //Included for the purpose of vectorization, but not used.
bool operator==(const char* str);
struct PeekPacket7
{
unsigned short fProtoSpec;
unsigned short fPacketLength;
unsigned short fSliceLength;
unsigned char fFlags;
unsigned char fStatus;
unsigned long fTimeStampHi;
unsigned long fTimeStampLo;
} ppacket;
struct PacketHeader
{
unsigned char fDestAddr[6];
unsigned char fSrcAddr[6];
unsigned short fProtocol;
unsigned char fPacketData[1500]; /* max packet size */
} enetpacket;
int length;
unsigned long packetCount;
char timeString[16];
};#if !defined(AFX_TRY5DOC_H__BA63042D_EFBE_45CF_A864_A01C9FB8E010__INCLUDED_) #define AFX_TRY5DOC_H__BA63042D_EFBE_45CF_A864_A01C9FB8E010__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <vector> struct PeekPacket7 { unsigned short fProtoSpec; unsigned short fPacketLength; unsigned short fSliceLength; unsigned char fFlags; unsigned char fStatus; unsigned long fTimeStampHi; unsigned long fTimeStampLo; }; struct PacketHeader { unsigned char fDestAddr[6]; unsigned char fSrcAddr[6]; unsigned short fProtocol; unsigned char fPacketData[1500]; /* max packet size */ }; class CPacket //Encapsulates data structs and associated information for easier instantiation. { public: CPacket(); virtual ~CPacket(); bool operator<(const char* str); //Included for the purpose of vectorization, but not used. bool operator==(const char* str); struct PeekPacket7 ppacket; struct PacketHeader enetpacket; int length; unsigned long packetCount; char timeString[16]; };
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
•
•
Originally Posted by Drowzee
Would it be worthwhile to typedef them as well?
•
•
•
•
Originally Posted by Drowzee
I use sizeof later on in grabbing information, so... might as well simplify the call, correct?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
•
•
Originally Posted by Drowzee
One last question:
One of the employees informed me that nesting structs inside the class was not good coding practice. How should I clean it up?
![]() |
Other Threads in the C++ Forum
- Previous Thread: libtiff
- Next Thread: hh:mm:ss format api
Views: 3482 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






