|
More site info...
C++ (Non Visual C++ Issues) | Forum profile
|
|
Forum profile page for C++ (Non Visual C++ Issues) on http://www.codeguru.com.
This report page is the aggregated overview from a single forum: C++ (Non Visual C++ Issues), located on the Message Board at http://www.codeguru.com.
This forum profile page summarizes the general forum statistics such as: Users Activity, Forum Activity, and Top Authors, which are reported in either a table or graph below for a given reporting time period.
Additional forum profile information for "C++ (Non Visual C++ Issues)" on the Message Board at http://www.codeguru.com is also shown in the following ways:
1) Latest Active Threads
2) Hot Threads for Last Week
Warning: These statistics are generated using 'best efforts' and can experience delays and reporting errors at times. Please note that such statistics do not constitute a forum's popularity and/or exact posting volumes at any given reporting period.
|
|
|
|
|
Posting activity on C++ (Non Visual C++ Issues):
|
|
Week
|
Month
|
3 Months
|
|
Threads:
|
155
|
497
|
1,589
|
|
Post:
|
487
|
1,725
|
6,016
|
|
|
C++ (Non Visual C++ Issues) Posting activity graph:
|
Top authors during last week:
user's latest post:
initializing static array
Published (2009-11-24 09:59:00)
The Boost MPL probably contains a way to do it. I'm not familiar enough with it to know exactly, how, though.
user's latest post:
C++ STL sample code by Rodney...
Published (2009-11-24 03:18:00)
The code is indeed erroneous. You need to qualify superclass functions and a typename is missing: Code: #include <vector> #include <map> /* HashMap class template; A usage example for vector, map, and function objects. Written by Rodney Myers, 3/4/00 */ namespace Containers { template <class Key, class Value, class HashFunc, class Pred=std::less<Key> > class HashMap: private...
user's latest post:
Bar Charts in C++? - Page 2 -...
Published (2009-11-24 11:16:00)
Quote: Originally Posted by potatoCode Would you prefer the solution on a silver plater like this Code: #include <iostream> #include <string> int main() { std::string ll1l; for(int ll(0), lll(4000),l1(0), ll1(5), l1l(100); ll++ != ll1 && (std::cout << "Sales amount: ", std::cin >>l1); std::cout << ll1l.append((l1 < 0 ||l1 >...
user's latest post:
static function to call member...
Published (2009-11-24 07:53:00)
Quote: Originally Posted by cpengr That crossed my mind. Ironically, part of what drew me to STL containers was not having to manage memory... Well, you do not have the manage the memory of the dynamic array of pointers even though you have to manage the memory for the object associated with each pointer. Quote: Originally Posted by cpengr oh well, guess I can't have my cake & eat it, too...but I do like to know what kinds of...
user's latest post:
Bar Charts in C++? - Page 2 -...
Published (2009-11-24 04:13:00)
okay well maybe the programming world is not for me then im just a student trying to pass the class that my teacher did not teach because i asked 5/25 students in the class and the teacher did not teach this material.
user's latest post:
Objects created on heap
Published (2009-11-24 09:02:00)
Quote: Originally Posted by karnavor Hello, If I create an object on the heap, then are the attributes of the object also stored on the heap? Eg. Code: class My_Class1 {}; class My_Class2 { public: My_Class1 x; My_Class2 *y; My_Class2() { x = My_Class1(); y = new My_Class1(); }; }; int main() { My_Class2 *my_object = new My_Class2(); } So my_object is created on the heap. When it's constructor is called, it also creates two instances of...
user's latest post:
v.pushback(v.back())
Published (2009-11-23 10:05:00)
At the point when the function call is made, v.back() is a valid reference. So I would argue it is the responsibility of the vector implementation to make sure that the operation is safe. In the real world, of course, we cannot always reley on that. Also the implementor might document that re-adding existing elements to the vector is unsafe.
user's latest post:
is there a way to include a...
Published (2009-11-23 19:58:00)
Quote: Originally Posted by Philip Nicoletti It is undefined to use sprintf on a std::string ... use stringstream You're right, I should have read the post more carefully. I thought he was asking about a char array.
user's latest post:
C++ File handling VS C file...
Published (2009-11-19 14:02:00)
Try this: Code: struct FileOpen{ FileOpen(FILE &* f, const char * name, const char * mode){ f = fopen(name, mode); fp = f; } ~FileOpen(void){ if (fp) fclose(fp); } FILE * fp; }; FILE * myfile; FileOpen fo(myfile, "c:\\test.txt", "w"); if (!myfile) return; That code will automatically close your file for you.
user's latest post:
Bar Charts in C++?
Published (2009-11-23 22:37:00)
Quote: for ( store1 = 0; store1 / 100; ++store1 ) ? let's think here for a moment. did store1 hold the value for the store 1? if so, you effectively destroyed its value. store1 / 100 isn't right. the first test would equal false since 0 / 100 is 0. ++store1... well would count up if it ran, but when would it stop? loop up how to use the for statement.....................
|
|
|
|
Latest active threads on C++ (Non Visual C++ Issues)::
Started 2 days, 12 hours ago (2009-11-24 08:59:00)
by Alex F
My_Class x will be created on the heap, embedded into My_Class2 my_object instance. You can think about this as "in-place allocation", which includes stack allocation for a local variable, and allocation inside of a parent object for class member.
My_Class2 *y will be always created on the heap, and pointer to it is kept inside of My_Class2 instance.
BTW, the line
x = My_Class1();
is not ...
Started 3 days, 18 hours ago (2009-11-23 03:24:00)
by treuss
Started 3 days, 7 hours ago (2009-11-23 14:48:00)
by Paul McKenzie
Go here:
http://www.oonumerics.org/blitz/examples/fft.cpp
Use the Taylor expansion instead of the function call. You will see template metaprogram version of sin() and cos(). You should use these in place of the arrays m_fCos and m_fSin.
Example:
Code:
#define M_PI 3.14159265358979323846
template<unsigned N, unsigned I>
class Sine {
public:
static ...
Started 3 weeks, 2 days ago (2009-11-03 14:45:00)
by laserlight
You declared the vector, but never defined it. Define it in a source file. You probably need to have the destructor remove the object from the vector.
Started 1 week, 2 days ago (2009-11-17 05:22:00)
by treuss
My advise: Don't mix reading and writing.
First read and parse: Create a struct contact (with members name, street, ...). Create a vector of contacts. Then start reading the file line by line. Check the tag name at the beginning of the line (skip spaces) and act accordingly:
<address_book>: ignore (unless you have to validate)
<contact> : Add a new contact object to your vector. Make ...
Started 3 days, 12 hours ago (2009-11-23 09:46:00)
by nuzzle
Quote:
Originally Posted by originalfamousjohnsmith
It's forcing me to use virtual methods, but there has to be some way around this. Anyone know?
Why do you want to avoid virtual functions?
Started 3 days, 3 hours ago (2009-11-23 18:41:00)
by treuss
feof will only return true, after the end-of-file has been read, i.e. after your call to fgets has failed. Your code does not check for failure of fgets but blindly believes that it has read something.
Started 6 days, 17 hours ago (2009-11-20 04:33:00)
by treuss
You enter "s". The code
Code:
int menu()
{
char ch;
// ....
cin >> ch;
fetches the 's' char from the buffer, leaving in "". gets_s fetches the '' (and nothing else).
Don't mix different functions for reading from the console . Best always use std::getline.
|
|
Hot threads for last week on C++ (Non Visual C++ Issues)::
Started 3 days, 18 hours ago (2009-11-23 03:24:00)
by treuss
Started 6 days, 17 hours ago (2009-11-20 04:15:00)
by rahul.kulshreshtha
try this
void inverted(int a)
{
if (a==1)
{
cout<<"*"<<endl;
}
else
{
inverted(a-1);
for (int i=0; i<a; i++)
{
cout<<"*";
}
cout<<endl;
}
}
Started 3 weeks, 2 days ago (2009-11-03 14:45:00)
by laserlight
You declared the vector, but never defined it. Define it in a source file. You probably need to have the destructor remove the object from the vector.
Started 1 week, 2 days ago (2009-11-17 17:38:00)
by Lindley
Use the modulus operator (%).
Alternatively, you could divide by 100 and then multiply by 100, and check if the result is the same as the original.
Started 3 days, 19 hours ago (2009-11-23 02:01:00)
by Alex F
Well, after testing I found that it is executed correctly. vector<int> is also OK. What problem do you have exactly?
Started 1 week, 1 day ago (2009-11-18 09:00:00)
by Philip Nicoletti
Why not use the vector or list class instead ?
Example usage for vector:
Code:
#include <vector>
#include <iostream>
int main()
{
std::vector<int> v;
v.push_back(1);
v.push_back(5);
std:: cout << v.size() << ""; // prints 2
return 0;
}
Also note:
Code:
int arraySize = sizeof(rawWaveDataArray);
printf("the array size is: %...
Started 1 week, 2 days ago (2009-11-17 05:22:00)
by treuss
My advise: Don't mix reading and writing.
First read and parse: Create a struct contact (with members name, street, ...). Create a vector of contacts. Then start reading the file line by line. Check the tag name at the beginning of the line (skip spaces) and act accordingly:
<address_book>: ignore (unless you have to validate)
<contact> : Add a new contact object to your vector. Make ...
Started 3 days, 8 hours ago (2009-11-23 12:59:00)
by Philip Nicoletti
I don't see how sscanf could read into a CString (without using
GetBuffer()). The easiest way might to read into char arrays,
and set the CStrings to the char arrays.
Code:
char szDay[10];
char szMonth[10];
sscanf( timeStampString, "%s time: %s %s %d %d:%d:%d %d", dummy, szDay, szMonth, &day, &hour, &min, &sec, &year);
dayName = szDay;
monthName = szMonth;
...
Started 1 week, 1 day ago (2009-11-18 16:26:00)
by VladimirF
Check out this link for " Conditional Operator: ? :"
Started 1 week, 2 days ago (2009-11-17 16:51:00)
by Paul McKenzie
Quote:
Originally Posted by jamesleighe
Let's say I have the following classes, inheriting each-other as shown...
First, please use code tags when posting, like this:
Code:
class ISystem
{
public:
virtual ~ISystem () {;}
virtual BOOL isInitialized () = 0;
};
class CSystem : public ISystem
...
|
|