Hello everyone,
What is wrong with the code, I just want to allocate an array of 100 void* pointers. :-) -
int main()
-
{
-
void** p;
-
-
p = new (void*) [100];
-
-
return 0;
-
}
-
>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C2143: syntax error : missing ';' before '['
1>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C3409: empty attribute block is not allowed
1>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C2143: syntax error : missing ']' before 'constant'
1>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C2143: syntax error : missing ';' before 'constant'
1>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C2143: syntax error : missing ';' before ']'
1>d:\visual studio 2008\projects\t est_void1\test_ void1\main.cpp( 5) : error C2143: syntax error : missing ';' before ']'
thanks in advance,
George
18 2251 Savage 1,764
Recognized Expert Top Contributor
You just remove those '()' around void*,and it should compile.
Use of void* deprecated in C++.
Thanks Savage,
Why adding () does not work, which C++ rule is violated?
You just remove those '()' around void*,and it should compile.
regards,
George
Why weaknessforcats ?
Any links for this topic and using what to replace void*?
Use of void* deprecated in C++.
regards,
George
Savage 1,764
Recognized Expert Top Contributor
Thanks Savage,
Why adding () does not work, which C++ rule is violated?
regards,
George
this is interpreted by compiler as: - p=(new unknown_type) (void*)[100];
because of new operator precedence.
p = new (void*) [100];
C++ ain't C.
In C++ new(void*) is a function named new that has a void* arguiment.
Why weaknessforcats ?
Any links for this topic and using what to replace void*?
Quote:
Originally Posted by weaknessforcats
Use of void* deprecated in C++.
Function overloading.
Savage 1,764
Recognized Expert Top Contributor
C++ ain't C.
In C++ new(void*) is a function named new that has a void* arguiment.
Function overloading.
What about this then: - void foo();
-
void (**p)();
-
-
p = new (void (*[3])());
-
p[0] = f;
-
-
//etc...
Is this interpreted as a overloaded function called new that takes a pointer to the array of generic function pointers,or does it allocate memory for p?
Thanks Savage,
I have tried your code can compile. What does the following statement mean?
p = new (void (*[3])());
what is the type of p? Could you interpret the meaning of right side of assignment and left side of assignment please?
What about this then: - void foo();
-
void (**p)();
-
-
p = new (void (*[3])());
-
p[0] = f;
-
-
//etc...
Is this interpreted as a overloaded function called new that takes a pointer to the array of generic function pointers,or does it allocate memory for p?
regards,
George
Thanks Savage,
Could you explain why the code will be explained to - p=(new unknown_type) (void*)[100];
please?
What is unknown_type comes from? What is new operator precedence?
this is interpreted by compiler as: - p=(new unknown_type) (void*)[100];
because of new operator precedence.
regards,
George
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: xuatla |
last post by:
Hi,
I encountered the following compile error of c++ and hope to get your help.
test2.cpp: In member function `CTest CTest::operator+=(CTest&)':
test2.cpp:79: error: no match for 'operator=' in '*this =
CTest::operator+(CTest&)((+t2))'
test2.cpp:49: error: candidates are: CTest CTest::operator=(CTest&)
make: *** Error 1
|
by: pavel.orehov |
last post by:
Hi,
I am using flex and bizon to write HTTP parser.
I am passing well flex and bison tools but can't compile their output.
================= Flex file (http_parser.lpp) ==============
%{
#include <iostream>
#include "http_parser.tab.hpp"
|
by: Chris LaJoie |
last post by:
Our company has been developing a program in C# for some time now, and we
haven't had any problems with it, but just last night something cropped up
that has me, and everyone else, stumped.
I have a struct that contains several different types of data. This struct
is used throuout the program. Now, when I compile, I get 6 errors, all of
them "Use of possibly unassigned field 'awayTime'" or "Use of possibly
unassigned field 'intlTime'"....
|
by: ranges22 |
last post by:
******************************************************************
I am compiling a librarry which has a .h file containing th
following:
******************************************************************
template<typename T> void from_string(const char Str, T &Obj);
template<> void from_string(const char Str, long &); //
template<> void from_string(const char Str, unsigned lon
&); //
|
by: electrixnow |
last post by:
Help!,
I need to compile this code with static libs so it run on another XP
machine that does'nt have
MS Studio installed. When I compile now I get an ERROR:
1>------ Rebuild All started: Project: drawing_control, Configuration:
Release Win32 ------
1>Deleting intermediate and output files for project 'drawing_control',
configuration 'Release|Win32'
| |
by: HugoScripts |
last post by:
hi there,
as i said i'm trying to compile a simple program that uses allegro, it's a small thing, indeed my goal was just to start using allegro, but until now i'm unable even to compile my simple program.
that's the program (i named it alle.c):
#include <stdio.h>
#include <stdlib.h>
|
by: Jonas Schneider |
last post by:
Heya,
don´t know if you know BOINC: it´s a system for distributed computing,
therefore distributing work to many computers and creating a little
super-computer, see also their homepage: http://boinc.berkeley.edu/.
I get the folllowing errors when I want to compile their default
application (WinXP, MSVC++E05):
|
by: Ioannis Vranos |
last post by:
Perhaps a mechanism can be introduced in the C++0x/1x standard,
something simple like defining a function as:
void somefunc(void) throw()
{
// ...
}
|
by: akhilesh.noida |
last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting
errors while configuring it. Please check and give your inputs for
resolving this.
configure command :
$ ../glibc-2.5/configure --prefix=/mnt/new/Mars/glibc_HQ_test/GLIBC/
install/ --with-__thread
--enable-kernel=2.6.11 --enable-shared
|
by: QiongZ |
last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template classes. One is List1, the other one is ListNode. The codes are below:
// test-linked-list.cpp :...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |