C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing Pointers
Goto page Previous  1, 2, 3, 4 ... 17, 18, 19  Next
 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
rossum
Guest





PostPosted: Sat Jan 28, 2006 10:00 pm    Post subject: Re: source files vs. resource files Reply with quote



On 27 Jan 2006 07:50:07 -0800, "Jackie" <Shuangshuang.Zhou (AT) gmail (DOT) com>
wrote:

Quote:
Hi all, I am new to visual c++, and found that each C++ project
automatically generates source files and resource files, what are their
roles, respectively? Thanks a lot.

The source files (*.cpp, *.h(pp)) are where the code that you actually
type is held. Resource files are specific to Windows and hold things
like Icons for your application. Resource files are off topic here,
you will get better information on them from a newsgroup dealing with
Windows.

rossum

--

The ultimate truth is that there is no ultimate truth
Back to top
Guest






PostPosted: Sun Jan 29, 2006 1:00 am    Post subject: Re: Subscript operator overloading with vectors Reply with quote



Thanks a lot guys for your posts and your comments.
Regarding Ben's (Ben Pope - because there are two Bens here)
suggestion of std::bitset - I cannot use it, because of the same
problem of providing a reference i.e. a pointer.

I finally got this working by declaring my own class - that had a
bool as its private member.
Thanks to all.
O.O.
Back to top
P.J. Plauger
Guest





PostPosted: Sun Jan 29, 2006 1:00 am    Post subject: Re: A dying era Reply with quote



"MikeB" <objectivedynamics (AT) hotmail (DOT) com> wrote in message
news:drg1vl$f6i$1$8302bc10 (AT) news (DOT) demon.co.uk...

Quote:
"P.J. Plauger" <pjp (AT) dinkumware (DOT) com> wrote in message
news:ue2dnQgZUcJXWCLeRVn-uw (AT) giganews (DOT) com...
What killed CUJ is what's been killing newspapers slowly for...

Are you saying that CMP intend to stop publishing a print version of CUJ?

Yes. The deed is done.

Quote:
I've searched the web and both the CMP and CUJ sites but can't see
anything about this. I accidentally let my subscription lapse so the
January issue was the last I got. I saw no mention of it there. If they
are dropping it, do you know which will be the last issue to ship?

February was the last issue, already shipped. There was very little notice,
either to the readership or to the staff.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Back to top
Ben Pope
Guest





PostPosted: Mon Jan 30, 2006 10:00 am    Post subject: Re: Subscript operator overloading with vectors Reply with quote

olson_ord (AT) yahoo (DOT) it wrote:
Quote:
Thanks a lot guys for your posts and your comments.
Regarding Ben's (Ben Pope - because there are two Bens here)
suggestion of std::bitset - I cannot use it, because of the same
problem of providing a reference i.e. a pointer.

I was assuming you could just use the std::bitset as your register:

typedef std::bitset<16> my16bitShiftRegister;

my16bitShiftRegister reg = 0x1234;
reg <<= 4; // reg contains 0x2340 (I think :)

I didn't know what other functionality you required.

Quote:
I finally got this working by declaring my own class - that had a
bool as its private member.
Thanks to all.
O.O.

Job done then!

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Back to top
Darko Miletic
Guest





PostPosted: Tue Jan 31, 2006 11:03 pm    Post subject: Re: memory mapped file stream Reply with quote

On 19 Jan 2006 09:39:38 -0800, "Divick" <divick.kishore (AT) gmail (DOT) com>
wrote:

Quote:
I can across common cpp library on gnu, which is cross platform (*nix
and windows only) which provides a portable MappedFile class using
which one can map, unmap and sync mapped files. But again it creates a
files which is what I don't want. Also just to have a mapped file, I
don't want to link with a totally new library.

Then write your ovn MemoryMappedFile class.
You will have one header and at least two cpp files. In one you will
implement class with unix functions and in another with windows API
functions for that.

That's what I did. It was couple of days worth spending.


Darko
Back to top
Guest






PostPosted: Thu Feb 02, 2006 8:01 am    Post subject: Re: List Iterator Not Incrementable? Reply with quote

red floyd,

I must admit that I did not write this code. I simply tried compiling
it for a friend under 2003, which worked, and 2005, which did not work.
I could not see a problem, when of course the problem was very
obvious. However, let's not pick it to pieces, shall we?

nate
Back to top
Ben Pope
Guest





PostPosted: Thu Feb 02, 2006 10:00 am    Post subject: Re: List Iterator Not Incrementable? Reply with quote

freckred76 (AT) hotmail (DOT) com wrote:
Quote:
red floyd,

I must admit that I did not write this code. I simply tried compiling
it for a friend under 2003, which worked, and 2005, which did not work.
I could not see a problem, when of course the problem was very
obvious. However, let's not pick it to pieces, shall we?

It's sometimes difficult to accept criticism, and if you post code to
this group it WILL be criticised heavily, but then, that's what you're
asking for. Learn from the criticism, don't take it personally.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Back to top
Stephan Brönnimann
Guest





PostPosted: Thu Feb 02, 2006 11:00 am    Post subject: Re: List Iterator Not Incrementable? Reply with quote

freckred76 (AT) hotmail (DOT) com wrote:
Quote:
Hi,

I think this might be a VC++ problem. I am using Microsoft Visual
Studio 2005 Full Version (8.0).

I have a simple for loop that iterates over a list using the standard
iterator. The list is populated with a struct _BLOCK defined as:

typedef struct
{
int iX ;
int iY ;
int iFrame ;
double dIntensity ;
} _BLOCK ;

std::list<_BLOCK> list_block;
std::list<_BLOCK>::iterator list_block_it;

for (list_block_it = list_block.begin (); list_block_it !=
list_block.end (); list_block_it++)
{
list_block_it->dIntensity -= 0.025 ;
if (list_block_it->dIntensity < 0.0)
{ // Delete this item
Rather than this obvious comment ...

.... I'd expect a rationale why the next element in the list is not
tested.

Quote:
list_block_it = list_block.erase (list_block_it);
}
}

The code seems fine to me, but it always fails an assert at run-time,
claiming "list iterator not incrementable." I haven't been able to
find any documentation or threads about this problem. Also, it seems
like this code runs fine when built with g++ or previous versions of
VC++.

Any help is greatly appreciated,

Nate

The correct way to remove element from a sequence is:
typedef std::list<int> List; // just a short-hand
typedef List::iterator Iter; // just a short-hand

List list;
for (Iter i = list.begin(); i != list.end()Wink {
if (*i < 0) i = list.erase(i);
else ++i;
}

Regards, Stephan
Back to top
Guest






PostPosted: Thu Feb 02, 2006 1:01 pm    Post subject: Re: List Iterator Not Incrementable? Reply with quote

freckred76 (AT) hotmail (DOT) com wrote:
Quote:
red floyd,

I must admit that I did not write this code. I simply tried compiling
it for a friend under 2003, which worked, and 2005, which did not work.

The VC2005 compiler is improved (duh). It catches many errors
immediately
whereas with the VC2003 compiler you would have other problems later
on.
Quote:
From experience, we prefer the VC2005 behavior. You can catch it before
the boss is looking Wink


Michiel.
Back to top
Scott J. McCaughrin
Guest





PostPosted: Thu Feb 09, 2006 3:03 am    Post subject: Re: virtual function and vtable Reply with quote

Kyle <invalid (AT) e (DOT) mail> wrote:
: kish_nand (AT) yahoo (DOT) com wrote:
: > Could someone please explain me the concept behind virtual functions
: > and vtables. I am little confused about this. Please refer to the

: there is no concept of vtable in c++, its up to compiler and its 'magic'
: how virtual function are actually implemented

: > following code and tell me how many virtual tables would be created and
: > what they would contain:
: >

Another poster wisely advised Lippman: his text "Inside the C++ Object
Model" describes this issue. Ti summarize, vtables are created (by some
compilers) on a per-class basis, so 3 vtables would result.
Back to top
Karthi
Guest





PostPosted: Sun Feb 19, 2006 2:06 pm    Post subject: Re: question about operator new Reply with quote

Hi,
First of all, new and delete keywords are used for allocating memory in
heap. Means, it will be dynamically allocated. But if you use double a[n],
it will be allocated in Stack Memory. Real purpose of dynamic allocation
will be destroyed. You may use malloc instead. If you are storing in stack
you are not supposed to delete it. It ll be deleted, right off it goes out
of scope in program execution.
Karthikeyan S










"carpenti" <bruno.carpentieri@uni-graz.at> wrote in message
news:dr0ccf$7d3$1 (AT) skirner (DOT) kfunigraz.ac.at...
Quote:
Dear all,

I am learning C++ and I got a little confused
about dynamic allocation of arrays. Any help
is greatly appreciated.
In the following piece of code, is the use of
the operator new strictly necessary ? I mean,
can I safely replace the line "a=new double[n];"
with "double a[n]", and keep "delete [] a;" to
free the reserved memory ? Many thanks in advance.

Best,
Bruno


~~~~~~~~~~~~~~~~~~~

#include <cstdlib
#include <iostream

using namespace std;

int main(int argc, char *argv[])
{

int n,i;
cin >> n;
double *a;

a=new double[n];

for (i=0; i<n ; i++)
a[i]=i;

delete [] a;
return 0;
}





Your
advice would be greatly appreciated !

Back to top
Karthi
Guest





PostPosted: Sun Feb 19, 2006 2:06 pm    Post subject: Re: How to delete an array? Reply with quote

Hi,
you may use STL Arrays or if you are using MFC, then use CArray sort of
things. Don try to reinvent a wheel.
Karthikeyan S
<felixnielsen (AT) hotmail (DOT) com> wrote in message
news:1137951600.545491.64000 (AT) f14g2000cwb (DOT) googlegroups.com...
Quote:
Hi, im pretty new to this so plz cut me some slag ;-)

anyhow, i need to delete an array, or what i really need is to increase
the array size, i was think i could be done by copying the array into a
temorary array of the same size, then delete the original, initiate the
old array again, but now with more spaces/cell or what u call it, then
copy the teporary array into the on just created and last delete the
temp array.
a bit complicated, but im told its the only way to do it...
Back to top
peter koch
Guest





PostPosted: Sun Feb 19, 2006 2:06 pm    Post subject: Re: question about operator new Reply with quote

carpenti skrev:

Quote:
Dear all,

I am learning C++ and I got a little confused
about dynamic allocation of arrays. Any help
is greatly appreciated.
In the following piece of code, is the use of
the operator new strictly necessary ? I mean,
can I safely replace the line "a=new double[n];"
with "double a[n]", and keep "delete [] a;" to
free the reserved memory ? Many thanks in advance.

Best,
Bruno


~~~~~~~~~~~~~~~~~~~

#include <cstdlib
#include <iostream

using namespace std;

int main(int argc, char *argv[])
{

int n,i;
cin >> n;
double *a;

a=new double[n];

for (i=0; i<n ; i++)
a[i]=i;

delete [] a;
return 0;
}





Your
advice would be greatly appreciated !

As said by others, n is not a compile-time constant, you do need to use
an array. My advice would be to use std::vector instead: a program that
calls delete - and delete [] in particular - should always raise your
suspicion: those programs are not using the advantage of C++. Thus
replace the lines
double *a;
a = new double[n]

with std::vector a(n)

and remove the delete[] statement.

/Peter
Back to top
Alf P. Steinbach
Guest





PostPosted: Thu Feb 23, 2006 11:06 pm    Post subject: Re: Is this legal? Reply with quote

* Mark P:
Quote:
I was helping a coworker port some code to a new compiler (HP). He had
something along the lines of this:

class C { // defined in the global namespace
static int foo();
};

namespace {
int C::foo() {...}
};

The compiler complained: A definition of a namespace declaration
must be written in directly in the namespace (unqualified) or in an
enclosing namespace (qualified).

The fix of course is obvious, and I'm not sure what his motivation was
to put only the definition in the unnamed namespace, but two other
compilers (Linux gcc and Sun) had not complained about this.

So I wonder, is his code standard compliant or not? (And if so, is
there any reason why one would want to do this?)

§9.3/2 "A member function function definition that appears outside of
the class definition shall appear in a namespace scope enclosing the
class definition."

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Back to top
Alf P. Steinbach
Guest





PostPosted: Thu Feb 23, 2006 11:06 pm    Post subject: Re: Is this legal? Reply with quote

* Victor Bazarov:
Quote:

(actually the use of 'static' declarator for
declaring non-member functions whose scope is limited to the file in which
they appear *was* deprecated).

Was it?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Back to top
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Goto page Previous  1, 2, 3, 4 ... 17, 18, 19  Next
Page 3 of 19

 
 


Powered by phpBB © 2001, 2006 phpBB Group