• Advertisement
Sign in to follow this  

Misc questions

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1. How to solve this in msvc6 ? #include <iostream> std::vector<int> v; tests.cpp(43) : error C2039: 'vector' : is not a member of 'std' 2. How to call to the constructor of a base class from the constructor of a inherent class ? and how to call to the constructor of a class, from the copy constructor of the same class ? 3. Is still useful the use of malloc/free in C++ ? or its "good-way" only use new/delete? 4. There is a way in msvc6 or 2003 to automatize the creation of a new file with some code? I mean: when you create a .h file, of name Texture.h, automatically, it creates the base code: #ifndef _TEXTURE_H_ #define _TEXTURE_H_ class Texture { private: public: Texture(); ~Texture(); }; #endif and when you create Texture.cpp, it creates: #include <Texture.h> Texture::Texture() { } ... thnx (I believe that I will go on)

Share this post


Link to post
Share on other sites
Advertisement
1. #include <vector>

3. You can still use malloc/free, but new/delete are considered "better" for some uses. Here's the FAQ entry for it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
@2
class A{ A(const std::string& n) : name(n) {}; std::string name};
class B{ B(const std::string& n) : A(n) {}};

Share this post


Link to post
Share on other sites
Quote:
Original post by Silly_con
4. There is a way in msvc6 or 2003 to automatize the creation of a new file with some code? I mean: when you create a .h file, of name Texture.h, automatically, it creates the base code:


To some extent you can.

You can supply a template file to VS 6 that it will copy to your new file, and/or you can write a macro to do it.

I use VS .NET, and the file goes in Vc7\vcprojectitems and has to be named correctly. I don't remember exactly where you put the template file in VS 6.

Here is the macro I use. I create an empty file and name it, and then run this macro on it:


''' Adds a generic file header based on file type
'''
Sub AddFileHeader()

Dim ext As String
Dim fileIsIncluded As Boolean
Dim symbol As String

Dim ext_pos As Integer = InStr(DTE.ActiveDocument.Name, ".")
If ext_pos = 0 Then
ext = ""
Else
ext = Mid(ActiveDocument.Name, ext_pos)
End If

fileIsIncluded = False

If ext = ".h" Then
symbol = UCase(Left(ActiveDocument.Name, ext_pos - 1)) + "_H_INCLUDED"
fileIsIncluded = True
ElseIf ext = ".inl" Then
symbol = UCase(Left(ActiveDocument.Name, ext_pos - 1)) + "_INL_INCLUDED"
fileIsIncluded = True
End If

Dim sel As TextSelection = DTE.ActiveDocument.Selection
sel.StartOfDocument()
Dim point As EditPoint = sel.TopPoint.CreateEditPoint()

DTE.UndoContext.Open("Add File Header")
Try
Dim blank_line As String = " "
Dim blank_len As Integer = Len(blank_line)
Dim name_len As Integer = Len(DTE.ActiveDocument.Name)
Dim left_len As Integer = Int((blank_len - name_len) / 2)
Dim name_line As String = Left(blank_line, left_len) + DTE.ActiveDocument.Name

point.Insert( _
"/** @file *//********************************************************************************************************" + vbLf + _
vbLf + _
name_line + vbLf + _
vbLf + _
" Copyright 2004, Your Name Here" + vbLf + _
" --------------------------------------------------------------------------------------------------------------" + vbLf + _
vbLf + _
" $Header: $" + vbLf + _
vbLf + _
" $NoKeywords: $" + vbLf + _
vbLf + _
" ********************************************************************************************************************/" + vbLf + _
vbLf)

If fileIsIncluded Then
point.Insert( _
"#pragma once" + vbLf + _
vbLf + _
vbLf)
End If

If Not ext = ".h" Then
point.Insert( _
"#include """ + Left(ActiveDocument.Name, ext_pos - 1) + ".h""" + vbLf + _
vbLf + _
vbLf)
End If
Finally
'If an error occured, then need to make sure that the undo context is cleaned up.
'Otherwise, the editor can be left in a perpetual undo context
DTE.UndoContext.Close()
End Try

End Sub



Share this post


Link to post
Share on other sites
thanks very much for help and links ! especially the vb macro,I have changed it and now works very well for me (and I have learned a bit vb :) )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement