Re: when to use C and when to use C++



Keith Thompson:

And we'd probably end up with something like C++...

C++ has the same array/pointer conversion rules as C (though it also
has STL vectors and so forth).

<OT>

Yes, but we can have references to arrays, and we can pass an array by
reference.

void Func(int (&arr)[5]) {}

Or more exotically:

#include <cstddef>

void Func(int *p,std::size_t len) {}

template<std::size_t len>
void Func(int (&arr)[len]) { Func(arr,len); }

int main()
{
int arr[5];

Func(arr);
}

</OT>



--

Frederick Gotham
.



Relevant Pages

  • Re: Im not REALLY a newbie, but.......
    ... If you choose to use only pointers and not references, ... begin with T being 'int', it is easy enough to see that the function must ... >distant past that swapped dynamic objects around (sorry, pointers to them!). ... >around with n-dimensional arrays, or arrays of strings (or should I say ...
    (alt.comp.lang.learn.c-cpp)
  • Suggestions for refactoring unusual tables
    ... id (int, primary key) ... systext (string) ... catalog_id ... type_id (int, references catalog_entry) ...
    (comp.databases)
  • [PATCH 1/3] vmscan: report vm_flags in page_referenced()
    ... eg. to protect executable file pages more aggressively. ... static inline int page_mkclean ... static int page_referenced_anon(struct page *page, ... the page we're checking references on. ...
    (Linux-Kernel)
  • RE: refreshview removes user defined functions from sysdepends
    ... May be this is a bug, It seems that sp_refreshview does not update references ... create table t(colA int) ... exec sp_refreshview myview ... > print 'check depenencies' ...
    (microsoft.public.sqlserver.programming)
  • [PATCH 1/3] vmscan: report vm_flags in page_referenced()
    ... eg. to protect executable file pages more aggressively. ... static inline int page_mkclean ... static int page_referenced_anon(struct page *page, ... the page we're checking references on. ...
    (Linux-Kernel)