473,785 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

could you please tell me whats the error in the code

39 New Member
i am using vc++ compiler
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3. class base
  4. {
  5. public:
  6.  
  7.     virtual void paint()
  8.     {
  9.         cout<<"in middle\n";
  10.     }
  11. };
  12.  
  13. class derived : public base
  14. {
  15. public:
  16.  
  17.     void paint()
  18.     {
  19.         cout<<"in derived\n";
  20.     }
  21.  
  22. };
  23. class middle 
  24. {
  25.     char str[10];
  26. public :
  27.     derived *getinfo()
  28.     {
  29.         cout<<"which object you want\n";
  30.             cin>>str;
  31.         if (str == "derived")
  32.         {             
  33.             return new(derived);
  34.         }
  35.     }
  36. };
  37. int main()
  38. {
  39.     middle m;
  40.     base *b;
  41.     //derived *d;
  42.     derived d;
  43.     b = m.getinfo();
  44.     b->paint();
  45.     getchar();
  46.     return 0;
  47.  
  48.  
  49. }
  50.  
  51.  
Unhandled exception at 0x00000000 in project.exe: 0xC0000005: Access violation reading location 0x00000000.

this is the error i am getting
Sep 22 '07 #1
3 1613
Ganon11
3,652 Recognized Expert Specialist
You can't compare strings using the == operator; you have to use strcmp.
Sep 22 '07 #2
diwakar09
39 New Member
You can't compare strings using the == operator; you have to use strcmp.

thanx this was a stupid mistake that i have done

thanx a lot once again
Sep 22 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
While we're at it, I see your are using C++ so why use C-style strings??

You should be using C++ string objects. These you can compare using the == operator.
Sep 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1761
by: Tony | last post by:
I found similar code for encoding/decoding strings in VB which works fine. However I wanted to use it in a C# projected and can't get it to work. When it executes the TransformFinalBlock() call at the end it always returns the error "System.Security.Cryptography.CryptographicException: Length of the data to decrypt is invalid." Can anyone see what I am doing wrong - I have tried playing with the lengths and the construction of the...
11
3142
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some useful utils that more pages on that server can use. As an example, I have created a Page Counter class that opens an Access .mdb file, counts the current entries for that page, and adds a new entry with some information regarding the current...
7
3712
by: Jim Butler | last post by:
I have this error that is happening on all of our web servers (production included). It basically started occurring once we loaded 2005 sql client tools, asp.net 2.0 (and all related prerequistes) on our windows 2003 web servers (unfortunately they are needed, so uninstalling is not an option). The web app where this happens, runs both asp code and .net 1.1 code within the same web app. In the asp app, we scrape and post data to .net 1.1...
1
1384
by: Asif Mohammed | last post by:
Hello, I have a databound datagridview, its allowed to add,remove and edit I type a value in (in new row), it uses e.cancel = true to invalidate the cell .. and does not let focus go away, but when the focus is in the cell (after invalidating) I click anywhere on form (focus still stays in cell) and then press escape .. and the row does not delete itself, it just blanks out. This is wrong behaviour, as it should delete. (which it does...
17
1790
by: Amy | last post by:
Hi, I finished this script and for some reason there is a delay every so often in the timing. Sometimes it seems two take 2 seconds instead of 1. Can anyone see anything that would slow it down? I sure can't see it. Thank you very much, Amy <body onload="changelink()"><a href="#" id="url"></a> arr = new Array(); arr = ; arr = ;
1
1995
by: yogesh | last post by:
i have a code as follows TServerDB() { fDB = Server()->dbStorage->Create(); } or fDB=TServer->TMySQLBD->Create(); can any one tell the relationship between two and whats the <between braces called
11
1466
thatos
by: thatos | last post by:
The code is below import java.io.*; class Storage{ int num = 0; String name = null; } public class gift1 { public static void main(String args) throws IOException{
3
6295
by: =?Utf-8?B?SGVyYg==?= | last post by:
I've developed an ASP.NET website that runs fine on my local WinXP IIS and on my server's IIS, both are IIS6.0 The site uses a master page that has the following declaration: <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="HVOA.master.vb" Inherits="HVOAWebsite.HVOA" %> The site will actually be hosted at an external hosting site, specifically GoDaddy.Com. So I moved the files to their site under a new virtual directory...
1
1400
by: koti688 | last post by:
Hi Mates, Can u please tell me whats happpenning in those. Please tell what ever u got. Outline the functinaliy in normal words. i am new to C++. I need to write SWIG wrapper which checks this C++ Code in perl. Please tell , what ever u understood . Thanks in advance #include <iostream> #include "stdafx.h"
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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,...
1
10090
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,...
0
8971
agi2029
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...
1
7499
isladogs
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...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.